[Issue 17545] [REG2.072] __traits(getAttributes, name) evaluates name to value prematurely

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Jun 24 10:52:41 PDT 2017


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

monkeyworks12 at hotmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monkeyworks12 at hotmail.com

--- Comment #1 from monkeyworks12 at hotmail.com ---
This code is *supposed* to be equivalent as far as I know, but it actually
fixes the issue. Change `@Attrib enum TEST = 123` to `@Attrib enum TEST { val =
123; }` and it will compile (you can also make it immutable; basically anything
that introduces an actual symbol).

I think it's because the compiler does not even see the enum; the symbol TEST
is replaced with the actual value at the usage site so it's like you're doing
`pragma(msg, __traits(getAttributes, 123))`, which of course doesn't make any
sense.

--


More information about the Digitalmars-d-bugs mailing list