https://issues.dlang.org/show_bug.cgi?id=14618
--- Comment #4 from [email protected] --- (In reply to Walter Bright from comment #2) > If I prepend: > > @safe: > > to the code: [...] > Error: cannot take address of local x in @safe function main Compile with `-dip1000` and add `scope` to `f`'s parameter and it compiles again: ---- @safe: struct S { immutable(int)* p; } inout(int)* f(scope inout S s) { inout(int)* result; auto dg = (inout(int)* p) {result = p;}; dg(s.p); return result; } void main() { immutable int x = 42; immutable int* p = &x; assert(*p == 42); /* passes */ scope(exit) assert(*p == 42); /* fails */ int* m = f(S(p)); /* uh-oh */ *m = 13; /* writing over immutable *p */ } ---- The `scope` on the parameter is wrong here, of course, but the compiler doesn't catch it. --
