[Issue 17449] [DIP1000] crash due to covariant conversion of scope delegate to delegate
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Mar 4 07:24:26 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=17449
Walter Bright <bugzilla at digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #2 from Walter Bright <bugzilla at digitalmars.com> ---
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.
--
More information about the Digitalmars-d-bugs
mailing list