May 22, 2017
https://issues.dlang.org/show_bug.cgi?id=16301

uplink.coder@googlemail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|nobody@puremagic.com        |uplink.coder@googlemail.com

--- Comment #8 from uplink.coder@googlemail.com ---
please try if
https://github.com/dlang/dmd/pull/6813
gives you the expected results.

--
May 23, 2017
https://issues.dlang.org/show_bug.cgi?id=16301

--- Comment #9 from Eyal <eyal@weka.io> ---
In the code review I saw that the PR changed the CTFE to use dynamic scoping lookup instead of lexical scoping so after much IRC back and forth I eventually managed to distill the problematic example to:

@safe:

unittest {
    struct Foo {
    @safe:
        int i;
        int whoami() { return i; }
        int call(int delegate() @safe dlg) {
            return dlg();
        }
    }
    int func() {
        auto foo1 = Foo(1);
        auto foo2 = Foo(2);
        assert(1 == foo2.call(&foo1.whoami));
        return 0;
    }
    enum F = func();
}

--
May 24, 2017
https://issues.dlang.org/show_bug.cgi?id=16301

--- Comment #10 from Eyal <eyal@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

--
1 2
Next ›   Last »