https://issues.dlang.org/show_bug.cgi?id=18548
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 Assignee: nob...@puremagic.com Reporter: j...@jackstouffer.com Consider ------ 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 https://github.com/dlang/phobos/blob/8f0094593c18466095da3156d6d574c93c26466c/std/format.d#L3627 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. --