Bug 13423 – Allow covariant assignment of lambda to delegate variable

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2014-09-04T22:45:00Z
Last change time
2014-09-18T17:34:54Z
Assigned to
nobody
Creator
hsteoh

Comments

Comment #0 by hsteoh — 2014-09-04T22:45:39Z
Code: ------ void main() { void delegate(char) dg = (dchar) {}; } ------ Compiler output (2.067alpha): ------ test.d(2): Error: cannot implicitly convert expression (__lambda1) of type void delegate(dchar _param_0) pure nothrow @nogc @safe to void delegate(char) test.d(2): Error: cannot implicitly convert expression (__lambda1) of type void delegate(dchar _param_0) pure nothrow @nogc @safe to void delegate(char) ------ There is no possible harm that can come from calling a pure nothrow @nogc @safe delegate via an impure/throwing/allocating/unsafe delegate pointer, so this assignment should be allowed. (Obviously, though, assigning in the other direction cannot be allowed.)
Comment #1 by yebblies — 2014-09-07T06:26:07Z
Is this issue 3075 again?
Comment #2 by k.hara.pg — 2014-09-07T07:30:03Z
(In reply to hsteoh from comment #0) > Code: > ------ > void main() { > void delegate(char) dg = (dchar) {}; > } > ------ There is a parameter type mismatching 'char' and 'dchar'.
Comment #3 by hsteoh — 2014-09-10T05:41:14Z
Oops, looks like I made a mistake while reducing the original test case. I'll have to go back and re-reduce it. Sorry for the noise.
Comment #4 by hsteoh — 2014-09-18T17:34:54Z
Looks like the original problem was something else. I'll file a different issue for it. Closing this one.