[Issue 17420] std.format.formatObject doesn't work with @safe toString specialization
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat May 27 06:15:36 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17420
--- Comment #3 from Nick Treleaven <nick at geany.org> ---
Sorry, yes (didn't have the source code to hand).
> If the toString overload is marked with any of these, hasToString!(YourType) == 0
class N
{
@nogc void toString(scope void delegate(const(char)[])@nogc sink);
}
hasToString!(N, char) is 2. I think the problem is:
class E : Throwable
{
override void toString(scope void delegate(const(char[]))@nogc sink) const;
}
Error: function E.toString does not override any function, did you mean to
override 'object.Throwable.toString'?
First, note that Throwable.toString takes a delegate with a const(char[])
parameter, not const(char)[], this is confusing and should be fixed.
Next, if you remove @nogc from sink above it compiles. Shouldn't dmd allow
overriding a method that takes a non- at nogc delegate with one that takes a @nogc
delegate?
--
More information about the Digitalmars-d-bugs
mailing list