https://issues.dlang.org/show_bug.cgi?id=17449
Issue ID: 17449 Summary: [DIP1000] crash due to covariant conversion of scope delegate to delegate Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: r.sagita...@gmx.de >From the dmd testsuite, runnable/xtest46.d: module test; struct Event9834 { void delegate() dg; void set(void delegate() h) pure { dg = h; } // AV occurs void call() { dg(); } } void main() { Event9834 ev; auto a = new class { Object o; this() { o = new Object; ev.set((){ o.toString(); }); } }; ev.call(); } This runs fine when compiled with "dmd test", but crashes with an access violation when compiled with "dmd test -dip1000". This is caused by the delegate being inferred as "scope", and implicitely converted to a non-scope delegate (thus not having a closure). This is ok when the delegate is called by the callee (Event9834.set) directly, but not if it is saved for later invocation. --