Based on a newsgroup post by Iain Buclaw. ---------- import std.stdio; class Outer { int w = 3; void method() { int x = 4; new class Object { this() { writefln("%d", x); // remove to suppress bug writefln("%d", w); writefln("%d", this.outer.w); } }; } } void main() { (new Outer).method(); } ----- DMD 1.067 ----- 4 3 4202691 ----- DMD 2.052 ----- 4 3 0 ---------- It would appear that DMD is getting confused over whether the context pointer of the inner class points to the stack frame of method or the Outer object. Which is it meant to be? Moreover, is the use of x inside the constructor meant to be legal? If the context pointer points to the Outer, it shouldn't be legal in methods, though I suppose it can still be allowed in the constructor.
I don't observe this behavior with DMD2.073. When was it fixed?
Works fine now.