https://issues.dlang.org/show_bug.cgi?id=22563
--- Comment #5 from Stanislav Blinov <stanislav.bli...@gmail.com> --- Well... the `static S s;` simply shouldn't compile at all for exactly that reason, so that's one extra bug: struct WTF(T) { static T x; void foo() { x.foo(); } } @safe void main() { int a; struct Nested { @safe: void foo() { ++a; } // boom1 ~this() { foo(); } // boom2 } } But the reason `consumeThingWithContext` is not inferred safe is the escape: Error: scope variable `s` assigned to non-scope parameter `p` calling context.main.Nested.opAssign The compiler is doing exactly the same thing for delegates too at the moment - it infers such escape as @system. A delegate is context + one function pointer. A nested struct is effectively a superset of that, with an added advantage of type information for function pointers. There's no reason (other than implementation complexity) to support allocation elision for one and not the other. --