https://issues.dlang.org/show_bug.cgi?id=20868
Bolpat <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #7 from Bolpat <[email protected]> --- (In reply to Walter Bright from comment #5) > To be specific, when compiled with -dip1000: > > void scoped (scope void delegate() dg) { > static void delegate()[] dgs; > dgs ~= dg; // Error: scope variable `dg` may not be copied into > allocated memory > } I only find the error message confusing. It should be an error: One cannot assign a scope object to a global state. Local static variables are not at global scope, but are a global state. Allowing that would make `scope` absolutely useless as a guarantee and for optimizations. When the function is called with a lambda, its can be allocated on the stack, because the reference won't "survive" the call. With allowing assignment to local static variables, this is no longer the case. --
