www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5346] New: instantiation of std.conv.toImpl and std.format.formatValue fails for unions

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

           Summary: instantiation of std.conv.toImpl and
                    std.format.formatValue fails for unions
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: elfy.nv gmail.com



import std.conv;
import std.format;
import std.stdio;

union U
{
    int a;
    float b;
}

struct S
{
    int t;
    U u;
}

void main()
{
    U u;
    writeln(text(u)); // error instantiation toImpl
    S s;
    writeln(text(s)); // error instantiation formatValue
}

patching templates in this manner:
-if (is(S == struct) && ...
+if ((is(S == struct) || is(S == union)) && ...
fixes it for me.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 12 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5346


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 09 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5346




Partial fixed in 2.055.
formatValue is now support union formatting.

void main()
{
    U u;
    //writeln(text(u)); // toImpl error instantiation toImpl
    writeln(u);         // Prints "U"
    S s;
    //writeln(text(s)); // toImpl error instantiation formatValue
    writeln(s);         // Prints "S(0, U)"
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 10 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5346


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED



Works in 2.060head.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 14 2012