Bug 20835 – Enum member attributes being evaluated in wrong scope.
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-05-16T02:36:29Z
Last change time
2020-05-20T01:05:09Z
Keywords
pull
Assigned to
No Owner
Creator
Jonathan Levi
Comments
Comment #0 by jonathanilevi — 2020-05-16T02:36:29Z
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 by boris2.9 — 2020-05-19T14:04:45Z
*** Issue 19344 has been marked as a duplicate of this issue. ***
Comment #2 by dlang-bot — 2020-05-19T14:41:28Z
@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 by dlang-bot — 2020-05-20T01:05:09Z
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