https://issues.dlang.org/show_bug.cgi?id=13085
Issue ID: 13085
Summary: Compiler does not reject storing global reference to
scope delegate
Product: D
Version: D2
Hardware: x86
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: DMD
Assignee: [email protected]
Reporter: [email protected]
Code:
------
int delegate() globDg;
void func(scope int delegate() dg) {
globDg = dg;
globDg();
}
void sub() {
int x;
func(() { return ++x; });
}
void trashme() {
import std.stdio;
writeln(globDg()); // prints garbage
}
void main() {
sub();
trashme();
}
------
--