[Issue 5154] New: Class Range does not work in writeln

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Nov 1 16:26:59 PDT 2010


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

           Summary: Class Range does not work in writeln
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: Jesse.K.Phillips+D at gmail.com
                CC: Jesse.K.Phillips+D at gmail.com


--- Comment #0 from Jesse Phillips <Jesse.K.Phillips+D at gmail.com> 2010-11-01 16:26:02 PDT ---
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()));
}

-- 
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