How come doing a foreach
on .tupleof
causes __traits(getAttributes
to return nothing? Is it because it creates a new 'symbol'? Is this a bug?
struct y{
int z;
}
struct X{
@y(z: 10) string x;
}
void main(){
X a;
foreach(b; a.tupleof){
pragma(msg, __traits(getAttributes, b)); //AliasSeq!()
}
}
Changing it to a static foreach
prints AliasSeq!(y(10))
as expected, but now I can't use b
in runtime code. Obviously there's a workaround, but it's ugly. I'd much prefer if the above code worked rather than having to do this:
static foreach(i; 0..a.tupleof.length){
pragma(msg, __traits(getAttributes, a.tupleof[i])); //AliasSeq!(y(10))
}