[Issue 13423] New: Allow covariant assignment of lambda to delegate variable
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Sep 4 15:45:39 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13423
Issue ID: 13423
Summary: Allow covariant assignment of lambda to delegate
variable
Product: D
Version: D2
Hardware: x86
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: hsteoh at quickfur.ath.cx
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.)
--
More information about the Digitalmars-d-bugs
mailing list