[Issue 21812] New: __traits(allMembers) on types with value tuples return ghost members

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 9 01:17:55 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=21812

          Issue ID: 21812
           Summary: __traits(allMembers) on types with value tuples return
                    ghost members
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: schveiguy at gmail.com

Consider the following code:

-----
struct S(A...)
{
   A args;
}

void main()
{
   pragma(msg, __traits(allMembers, S!(int, float)));
} 
----

This outputs the following:

tuple("args", "__args_field_0", "__args_field_1")

The members __args_field_0 and __args_field_1 don't exist on the type:

---
S!(int, float) s;

// all of these produce the error: no property __args_field_0 for type S!(int,
float)
writeln(s.__args_field_0);
writeln(__traits(getMember, s, "__args_field_0"));
pragma(msg, __traits(identifier, __traits(getMember, typeof(s),
"__args_field_0")));
---

I would contend that __traits(allMembers) should not ever return strings that
are not accessible in any way as a member.

--


More information about the Digitalmars-d-bugs mailing list