Issue ID: 18548
           Summary: [2.079 Beta] std.format ignores templated toString if
                    another toString is not a template
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: phobos


import std.format;
import std.range;

struct A(T)
    string toString() const { return ""; }
    void toString(W)(ref W w) const { put(w, ""); }

struct B(T)
    string toString()() const { return ""; }
    void toString(W)(ref W w) const { put(w, ""); }

void main()
    // hasToString is a private template of std.format
    pragma(msg, hasToString!(A!(int), char)); // 1
    pragma(msg, hasToString!(B!(int), char)); // 5

The issue comes from this line

Because the first toString overload in A is not a template but a function, the
attempted instantiation of the toString template inside hasToString always
fails despite the fact that there is an existing toString template.


Reply via email to