__traits(allMembers) includes weird symbols for structs with tuples

user1234 user1234 at 12.de
Fri Apr 9 02:57:51 UTC 2021


On Friday, 9 April 2021 at 00:15:10 UTC, Steven Schveighoffer 
wrote:
> This:
>
> ```d
> struct S(A...)
> {
>     A args;
> }
>
> [...]
> Why is __traits(allMembers) returning things that aren't 
> members in any way, shape or form?
>
> Bug?
>
> -Steve

Bug.

Even if args is usually only designed to be called using an 
IndexExp what appens is that for each tuple element a VarDecl is 
created. Those declarations are not added to the scope symtab. 
Adding them to the symtab makes your example to compile and I 
think that it's a better solution than filtering allMembers 
results as a special case is avoided.


More information about the Digitalmars-d mailing list