June 04, 2019
https://issues.dlang.org/show_bug.cgi?id=19938

          Issue ID: 19938
           Summary: CTFE duplicates calls to function when it is used as
                    LHS of slice assignment
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: eyal@weka.io

struct foo {
    int count;
    int[] x() { count++; return []; }
}

auto check() {
    foo f;
    f.x[] = 1;
    f.x[] = 2;
    assert(f.count == 2); // fails in CTFE only, where f.count == 4, x() calls
are duplicated only in CTFE
    return true;
}

unittest {
    check(); // works
    static assert(check());
}

--