www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6456] New: toString fails with alias this when more than one field present

reply d-bugmail puremagic.com writes:
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: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



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: -------
Aug 08 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6456


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

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



07:03:57 PST ---
Fixed in 2.057, but I don't know which pull fixed it.

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