Bug 5371 – ambiguous stringnize of class with alias this

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-12-24T16:24:00Z
Last change time
2011-09-10T21:15:36Z
Assigned to
nobody
Creator
k.hara.pg

Attachments

IDFilenameSummaryContent-TypeSize
854format_fix.patchfix formatValuetext/plain1639
855issue5371.patchfix formatValuetext/plain1565

Comments

Comment #0 by k.hara.pg — 2010-12-24T16:24:10Z
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 [] */ } ----
Comment #1 by k.hara.pg — 2010-12-24T16:25:08Z
Created attachment 854 fix formatValue
Comment #2 by k.hara.pg — 2010-12-24T16:40:38Z
Created attachment 855 fix formatValue I fixed patch bug.
Comment #3 by k.hara.pg — 2010-12-24T16:50:04Z
Comment #4 by k.hara.pg — 2011-09-10T07:31:49Z
In dmd 2.055
Comment #5 by k.hara.pg — 2011-09-10T21:15:36Z