Bug 5154 – Class Range does not work in writeln

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-11-01T16:26:00Z
Last change time
2010-11-16T13:05:42Z
Assigned to
rsinfu
Creator
Jesse.K.Phillips+D

Comments

Comment #0 by Jesse.K.Phillips+D — 2010-11-01T16:26:02Z
The code below fails to compile because a Class with InputRange primitives sanctifies two std.format.formatValue functions. On is for printing Classes and the other for printing an InputRange. This is not an issue when using std.string.format (Since it doesn't use formatValue). C:\opt\dmd\windows\bin\..\..\src\phobos\std\format.d(1455): 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 templat e declaration, C:\opt\dmd\windows\bin\..\..\src\phobos\std\format.d(1126):format Value(Writer,T,Char) if (isInputRange!(T) && !isSomeChar!(ElementType!(T))) and C:\opt\dmd\windows\bin\..\..\src\phobos\std\format.d(1297):formatValue(Writer,T, Char) if (is(T == class)) import std.stdio; import std.string; class Range { bool empty() { return true; } int front() { return 1; } void popFront() { } } void main() { writefln("%s", new Range()); writeln(new Range()); writeln(format("%s", new Range())); }
Comment #1 by rsinfu — 2010-11-16T13:03:13Z
Fixed: http://www.dsource.org/projects/phobos/changeset/2170 Also fixed for interfaces and pointers to struct ranges.
Comment #2 by rsinfu — 2010-11-16T13:04:06Z
Fixed: http://www.dsource.org/projects/phobos/changeset/2170 Also fixed for interfaces and pointers to struct ranges.