D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20835 - Enum member attributes being evaluated in wrong scope.
Summary: Enum member attributes being evaluated in wrong scope.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-05-16 02:36 UTC by Jonathan Levi
Modified: 2020-05-20 01:05 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jonathan Levi 2020-05-16 02:36:29 UTC
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.
Comment 1 Boris Carvajal 2020-05-19 14:04:45 UTC
*** Issue 19344 has been marked as a duplicate of this issue. ***
Comment 2 Dlang Bot 2020-05-19 14:41:28 UTC
@BorisCarvajal created dlang/dmd pull request #11163 "Fix issue 20835 - Enum member attributes being evaluated in wrong scope." fixing this issue:

- Fix issue 20835 - Enum member attributes being evaluated in wrong scope.

https://github.com/dlang/dmd/pull/11163
Comment 3 Dlang Bot 2020-05-20 01:05:09 UTC
dlang/dmd pull request #11163 "Fix issue 20835 - Enum member attributes being evaluated in wrong scope." was merged into stable:

- d76f8c37f637e9b393eef0306c4467566e1044fd by Boris Carvajal:
  Fix Issues 20835, 19344 - Enum member attributes being evaluated in wrong scope.

https://github.com/dlang/dmd/pull/11163