[Issue 23241] New: __traits getMember breaks compilation when hit an alias

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 13 01:11:19 UTC 2022


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

          Issue ID: 23241
           Summary: __traits getMember breaks compilation when hit an
                    alias
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: ryuukk.dev at gmail.com

```
onlineapp.d(12): Error: first argument is not a symbol
```

```
module a;
import std;

@("hi")
void main()
{    
    alias THIS_MODULE = a;
    static foreach (member; __traits(allMembers, THIS_MODULE))
    {
        writeln("member: ", member);
        static foreach (attr; __traits(getAttributes, __traits(getMember,
THIS_MODULE, member))) 
        {
            writeln("\tattribute: ", attr);
        }
    }
}

enum :int
{
    A, B, C
}

// commenting this out fixes it
alias MyEnum = int;
``` 

Expected behavior:

It should ignore either ignore the alias and compile, or support the alias

--


More information about the Digitalmars-d-bugs mailing list