http://d.puremagic.com/issues/show_bug.cgi?id=2939
Summary: lazy evaluation not invoked for lambda function Product: D Version: 2.029 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzi...@digitalmars.com ReportedBy: crist...@zerobugs.org The following code illustrates how a lambda function is not evaluated when the caller is inside of a foreach block. class X { int bogus; int opApply(int delegate(ref X) dg) { return dg(this); } } void f(lazy void dg) { dg(); } void main() { bool ok = false; void okay() { ok = true; } X x = new X; foreach(elem; x) { f({ok = true;}); // ASSERTION WILL FAIL FOR LAMBDA //f (okay); // works okay for other functions } assert(ok); } --