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


--- Comment #0 from Nick Voronin <elfy.nv gmail.com> 2010-12-12 19:07:13 PST ---
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



--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2011-09-10 11:50:43 PDT ---
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


--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2012-06-14 02:40:29 PDT ---
Works in 2.060head.

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