www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21812] New: __traits(allMembers) on types with value tuples

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 puremagic.com
          Reporter: schveiguy 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.

--
Apr 08