__traits(allMembers) includes weird symbols for structs with tuples
Steven Schveighoffer
schveiguy at gmail.com
Fri Apr 9 00:15:10 UTC 2021
This:
```d
struct S(A...)
{
A args;
}
void main()
{
pragma(msg, __traits(allMembers, S!(int, float)));
}
```
outputs this:
```
tuple("args", "__args_field_0", "__args_field_1")
```
What happens if you try to access __args_field_0, etc?
```d
void main()
{
S!(int, float) s;
import std.stdio;
writeln(s.__args_field_0); // Error: no property __args_field_0 for
type S!(int, float)
writeln(__traits(getMember, s, "__args_field_0")); // same error
pragma(msg, __traits(identifier, __traits(getMember, typeof(s),
"__args_field_0"))); // same error
}
```
Why is __traits(allMembers) returning things that aren't members in any
way, shape or form?
Bug?
-Steve
More information about the Digitalmars-d
mailing list