[Issue 17641] TypeInfo for two identical delegates (or functions) are not equal to each other

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Jul 12 09:20:40 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17641

ag0aep6g at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g at gmail.com

--- Comment #1 from ag0aep6g at gmail.com ---
(In reply to andronkin from comment #0)
> auto d1 = delegate void(uint a) { writeln(a); };
> auto d2 = delegate void(uint a) {};
> 
> assert(typeid(d1) is typeid(d2)); // FAILED! Although type hasn't been
> changed...

The type of d1 has changed. Try printing them with `pragma(msg, ...)`:

----
pragma(msg, typeof(d1));
pragma(msg, typeof(d2));
----

Prints:

----
void delegate(uint a) @safe
void delegate(uint a) pure nothrow @nogc @safe
----

You see that d1 is not `pure nothrow @nogc`. Because `writeln` isn't.

> Also, the string representation of typeid(d1) is "void delegate()", although
> there must be a "void delegate(uint)".

Yeah, that looks wrong.

--


More information about the Digitalmars-d-bugs mailing list