www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12039] New: "tupleof" ignores named unions

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12039

           Summary: "tupleof" ignores named unions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: monarchdodra gmail.com



Using tupleof, named unions are not taken into account. Anonymous unions seem
to work "just fine":

//----
import std.stdio;
import std.traits;

void main() 
{
    S s;
    writeln(s.tupleof);
    writeln(FieldTypeTuple!S.stringof);
}
//----

//----
struct S
{
    union
    {   
        int a;
        int b;
    }   
}
//Produces:
00
(int, int)
//----

//----
struct S
{
    union u
    {   
        int a;
        int b;
    }   
}
//Produces:

()
//----

This is quite bothersome, as it impacts FieldTypeTuple too.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 29 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12039




Seems to also affect RepresentationTypeTuple

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 30 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12039


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




 struct S
 {
     union u
     {   
         int a;
         int b;
     }   
 }
It declares an union type inside struct S. a and b are in u, not in S. Therefore, struct S has no field, then s.tupleof.length == 0. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 30 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12039





 It declares an union type inside struct S. a and b are in u, not in S.
 Therefore, struct S has no field, then s.tupleof.length == 0.
Thanks :( -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 30 2014