Bug 5346 – instantiation of std.conv.toImpl and std.format.formatValue fails for unions

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-12-12T19:07:00Z
Last change time
2012-06-14T02:40:29Z
Keywords
patch, rejects-valid
Assigned to
andrei
Creator
elfy.nv

Comments

Comment #0 by elfy.nv — 2010-12-12T19:07:13Z
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.
Comment #1 by k.hara.pg — 2011-09-10T11:50:43Z
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)" }
Comment #2 by k.hara.pg — 2012-06-14T02:40:29Z
Works in 2.060head.