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

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)

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


Reply via email to