https://issues.dlang.org/show_bug.cgi?id=24265
Paul Backus <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|ref delegate no longer |ref delegate literal no |implicitly converts to |longer implicitly converts |unannotated type |to unannotated type --- Comment #6 from Paul Backus <[email protected]> --- The bug *is* related to dropping function attributes during implicit conversion, and it only affects a delegate whose type is inferred from the type of a delegate literal: --- void test() { int local; auto inferred = delegate ref int() => local; ref int fun() pure nothrow @nogc @safe; static assert(is(typeof(inferred) == typeof(&fun))); typeof(&fun) explicit = inferred; ref int f(); typeof(&f) dg; dg = &fun; // ok dg = explicit; // ok dg = inferred; // error } --- Output: --- bug.d(17): Error: cannot implicitly convert expression `inferred` of type `int delegate() pure nothrow @nogc ref @safe` to `int delegate() ref` --- Somehow, the compiler is ending up with two internal representations of the "same" delegate type, and only one of them can implicitly convert to the unannotated version. --
