How to do reflection on alias symbols

Arafel er.krali at gmail.com
Thu Nov 16 10:03:25 UTC 2023


Hi all,

Please consider the following currently non-working code:

```d
struct bar {
     public alias pubInt = int;
     private alias privInt = int;
}

static foreach(member ; __traits(allMembers, bar)) {
     // Error: argument `int` has no visibility
     pragma(msg, __traits(getVisibility, __traits(getMember, bar, member)));
}
```

Is there any way to get the visibility, or more generically to reflect 
on an alias member as itself and not as the symbol pointed to without 
resorting to nasty __trait(compiles,...) tricks that fail more often 
than not?


More information about the Digitalmars-d-learn mailing list