[Issue 19056] UDAs can be added to imports but not retrieved

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 6 09:50:48 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19056

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305 at gmail.com

--- Comment #1 from RazvanN <razvan.nitu1305 at gmail.com> ---
It seems that UDAs do not work with aliases and `@X import y = std.stdio;`
creates an alias behind the scenes. Note that:

enum X;
int a;
@X alias g = a;
pragma(msg, __traits(getAttributes, g));

prints an empty tuple too because __traits(getAttributes) first resolves the
symbol and then checks if any attributes exist in order to accomodate this
case:

enum X;
@X int a;
alias g = a;
pragma(msg, __traits(getAttributes, g));

prints tuple((X)).

In my opinion, the best solution would be to make adding UDAs to aliases
illegal and also not allow UDAs to imports as long as imports create aliases
behind the scenes.

--


More information about the Digitalmars-d-bugs mailing list