[Issue 20835] New: Enum member attributes being evaluated in wrong scope.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat May 16 02:36:29 UTC 2020


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

          Issue ID: 20835
           Summary: Enum member attributes being evaluated in wrong scope.
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: jonathanilevi at gmail.com

Accessing enum member attributes, throwing an "undefined identifier" error (at
CT), if the attributes of the member are not first accessed in the scope which
the attribute is defined in.

This code exemplifies the error:
```
import std;

template T(E) {
    pragma(msg, __traits(getAttributes, E.a));
    enum T = null;
}

void main() {
    class C {}
    enum E {
        @C a
    }
    ////pragma(msg, __traits(getAttributes, E.a));
    pragma(msg, T!E);
}
```

Uncommenting the commented out line, makes the error not happen.

--


More information about the Digitalmars-d-bugs mailing list