[Issue 5371] New: ambiguous stringnize of class with alias this

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 24 16:26:10 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=5371

           Summary: ambiguous stringnize of class with alias this
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2010-12-24 16:24:10 PST ---
We can't compile this code if enable the line:26 or line:34.
----
import std.array;
import std.format;
class C1
{
    const(string) var = "C1";
    alias var this;
}
class C2
{
    string var = "C2";
    alias var this;
}
void main()
{
    FormatSpec!char f;
    auto a = appender!string();

    auto c1 = new C1();
    auto c2 = new C2();

//  formatValue(a, c1, f);  // line:21
/*
If enable this line, 
test.d(21): Error: template std.format.formatValue(Writer,T,Char) if
(is(const(T) == const(void[]))) formatValue(Writer,T,Char) if (is(const(T) ==
const(void[])
)) matches more than one template declaration,
C:\d\dmd2\src\phobos\std\format.d(1092):formatValue(Writer,T,Char) if
(isSomeString!(T) && !isStaticArray!(T)) an
d C:\d\dmd2\src\phobos\std\format.d(1346):formatValue(Writer,T,Char) if (is(T
== class) && !isInputRange!(T))
*/

//  formatValue(a, c2, f); // line:29
/*
If enable this line,
C:\d\dmd2\src\phobos\std\format.d(1097): Error: test.C2 cannot be sliced with
[]
*/
}
----

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


More information about the Digitalmars-d-bugs mailing list