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


--- Comment #0 from monarchdodra gmail.com 2014-01-29 23:45:43 PST ---
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



--- Comment #1 from monarchdodra gmail.com 2014-01-30 00:30:49 PST ---
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


--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2014-01-30 01:12:50 PST ---
(In reply to comment #0)
 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



--- Comment #3 from monarchdodra gmail.com 2014-01-30 02:26:13 PST ---
(In reply to comment #2)
 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