Mixin and introspection ordering

Sebastiaan Koppe mail at skoppe.eu
Tue Oct 15 19:19:58 UTC 2019


Sometimes ordering is important when combining mixins and 
introspection, this is another such case:

```
import std.traits;

enum myuda;

mixin template Slot(string name) {
     mixin("@myuda int "~name~";");
}

struct OuterOption {
     mixin Slot!"a";
}

struct App {
     pragma(msg, getSymbolsByUDA!(OuterOption, myuda).stringof); 
// 1. prints 'tuple(a)'
//  pragma(msg, getSymbolsByUDA!(InnerOption, myuda).stringof); 
// 2. prints '()'
     struct InnerOption {
         mixin Slot!"a";
     }
     pragma(msg, getSymbolsByUDA!(InnerOption, myuda).stringof); 
// 3. prints 'tuple(a)'
}
```

You would expect 2 to print `tuple(a)` as well, but it doesn't. 
Don't know if it is a bug.


More information about the Digitalmars-d-learn mailing list