Skip to content

Commit

Permalink
Add another test for #7879
Browse files Browse the repository at this point in the history
  • Loading branch information
wilzbach committed Feb 23, 2018
1 parent 502aed8 commit ab93c46
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions std/format.d
Expand Up @@ -3868,6 +3868,26 @@ version(unittest)
assert(s == "shared(std.format.C)");
}

// https://issues.dlang.org/show_bug.cgi?id=7879
@safe unittest
{
class F
{
override string toString() const @safe
{
return "Foo";
}
}

const(F) c;
auto s = format("%s", c);
assert(s == "null");

const(F) c2 = new F();
s = format("%s", c2);
assert(s == "Foo", s);
}

// ditto
private void formatValueImpl(Writer, T, Char)(auto ref Writer w, T val, const ref FormatSpec!Char f)
if (is(T == interface) && (hasToString!(T, Char) || !is(BuiltinTypeOf!T)) && !is(T == enum))
Expand Down

0 comments on commit ab93c46

Please sign in to comment.