http://d.puremagic.com/issues/show_bug.cgi?id=6456
Summary: toString fails with alias this when more than one field present Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: andrej.mitrov...@gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrov...@gmail.com> 2011-08-08 11:22:46 PDT --- import std.stdio; import std.conv; struct Foo { string toString() { return to!string(x); } alias x this; int x; int y; // comment this out and the bug is gone } void main() { auto foo = Foo(); writeln(foo); } If you comment out "int y;" the bug is gone, otherwise you get back this little thingy: D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\conv.d(100): Error: template std.conv.toImpl(T,S) if (!implicitlyConverts!(S,T) && isSomeString!(T) && isInputRange!(Unqual!(S)) && isSomeChar!(ElementType!(S))) does not match any function template declaration D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\conv.d(100): Error: template std.conv.toImpl(T,S) if (!implicitlyConverts!(S,T) && isSomeString!(T) && isInputRange!(Unqual!(S)) && isSomeChar!(ElementType!(S))) cannot deduce template function from argument types !(int)(Foo) D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\conv.d(100): Error: template instance errors instantiating template D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\format.d(1683): Error: template instance std.conv.to!(int).to!(Foo) error instantiating D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\format.d(328): instantiated from here: getNthInt!(Foo) D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(678): instantiated from here: formattedWrite!(LockingTextWriter,immutable(char),Foo) D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(1511): instantiated from here: write!(Foo,char) test.d(18): instantiated from here: writeln!(Foo) D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\format.d(328): Error: template instance std.format.getNthInt!(Foo) error instantiating D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(678): instantiated from here: formattedWrite!(LockingTextWriter,immutable(char),Foo) D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(1511): instantiated from here: write!(Foo,char) test.d(18): instantiated from here: writeln!(Foo) Failed: dmd -d -debug -w -wi -unittest -v -o- "test.d" -I"." >test.d.deps -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------