April 29, 2021 [Issue 21878] New: "ref" lost when indexing array in CTFE | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=21878 Issue ID: 21878 Summary: "ref" lost when indexing array in CTFE Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: CTFE Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: dlang-bugzilla@thecybershadow.net ///////////////////////////////// test.d //////////////////////////////// struct A { int i; ref inout(int) opIndex(size_t idx) inout return { return i; } } struct B { A[1] a; ref inout(int) opIndex(size_t idx) inout return { return a[0][idx]; } } bool ctfeFunc() { A a; a[0] = 42; assert(a[0] == 42); // OK B b; b[0] = 42; assert(b[0] == 42); // fails return true; } enum eval = ctfeFunc(); unittest { ctfeFunc(); // succeeds at runtime } ///////////////////////////////////////////////////////////////////////// It looks like the assignment is going into some rvalue which is then lost. -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply