__traits(allMembers) includes weird symbols for structs with tuples

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Apr 9 00:32:20 UTC 2021


On Thu, Apr 08, 2021 at 08:15:10PM -0400, Steven Schveighoffer via Digitalmars-d wrote:
[...]
> ```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?
[...]

I suspect it's returning internal compiler implementation details that
aren't supposed to be accessible to user code. That, or introspecting
this particular type was overlooked when this was implemented.

I'd file an issue in bugzilla.


T

-- 
There are 10 kinds of people in the world: those who can count in binary, and those who can't.


More information about the Digitalmars-d mailing list