Mike L. Wrote: > The following code compiles fine for me with dmd 1.043:
At least for closures, D2 will catch this type of issue. I doubt such escaping stack frame issues will get addressed in D1. Either way, you should submit a bugzilla entry. > > ---------- > module wtf; > > version(Tango) > import tango.io.Stdout; > else > import std.stdio; > > interface Printer > { > void print(); > } > > class WTF > { > Printer p; > > this(int x) > { > p = new class Printer > { > override void print() > { > version(Tango) > Stdout(x).newline(); > else > writefln(x); > } > }; > } > } > > void main() > { > WTF wtf = new WTF(42); > wtf.p.print(); > } > ---------- > > The anonymous class is given a method that prints the int x, however, by the > time wtf.p.print() is called, x has gone out of scope. It's still possible to > call the print(), though, and it just prints garbage. Should this be a > compiler error?