https://issues.dlang.org/show_bug.cgi?id=16301

--- Comment #10 from Eyal <e...@weka.io> ---
Sorry, this is the actual example that showed the dynamic scoping lookup in the
PR is incorrect:

@safe:

unittest {
    enum Caller { OpApply, Other }
    struct OpApply {
        @safe:
        int delegate(Caller) @safe myDlg;
        int opApply(int delegate(Caller) @safe dlg) {
            myDlg = dlg;
            return dlg(Caller.OpApply);
        }
    }
    struct Foo {
        @safe:
        OpApply o;
        int i;
        this(int x) {
            i = x;
            o = OpApply();
            foreach(caller; o) {
                final switch(caller) {
                case Caller.OpApply:
                    if(i == 1) {
                        auto foo2 = Foo(2);
                        assert(2 == foo2.call(o.myDlg));
                        assert(i == 0);
                    }
                    break;
                case Caller.Other:
                    i = 0;
                    break;
                }
            }
        }

        int call(int delegate(Caller) @safe dlg) {
            dlg(Caller.Other);
            return i;
        }
    }
    Foo(1);
}

The distilled one somehow

--

Reply via email to