https://issues.dlang.org/show_bug.cgi?id=20969
Simen Kjaeraas <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #2 from Simen Kjaeraas <[email protected]> --- I'm not sure this is exactly the same issue, but it's certainly analogous: unittest { import std.stdio; int i; writeln("Outside: ", &i); static fn = (){ writeln("Inside: ", &i); ++i; }; writeln("Context: ", fn.ptr); fn(); } Output: Outside: 3100014 Context: null Inside: 4 (0): [unittest] Access Violation As we can see, the context pointer for the delegate is not initialized. Making it compile would either be equivalent to making 'i' static, or have different behavior for the first and consequent calls, as only the first would have its 'i' modified by calls to fn(). Sensible workarounds do exist, this is most likely to be a mistake by the programmer, and having it work requires that this corner case be described somewhere. I say make it an error. --
