https://issues.dlang.org/show_bug.cgi?id=17449
Walter Bright <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #2 from Walter Bright <[email protected]> --- Adding `@safe` to main() causes the compiler error message: test.d(8): Error: `@safe` function `D main` cannot call `@system` delegate `dg` which looks appropriate. Adding more @safe: @safe void main() { void delegate() @safe dg; void savedg(void delegate() @safe h) { dg = h; } void foo(int x) { savedg({ assert(x == 42); }); } foo(42); dg(); } Makes it compile and run successfully. Checking the generated code, it is generating a closure. So it looks correct. -dip1000 isn't enough, using @safe is also necessary. --
