digitalmars.D.bugs - [Issue 21104] New: certain array operations fail during CTFE when
- d-bugmail puremagic.com (28/28) Aug 02 2020 https://issues.dlang.org/show_bug.cgi?id=21104
https://issues.dlang.org/show_bug.cgi?id=21104 Issue ID: 21104 Summary: certain array operations fail during CTFE when used to initialize a static array Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: rejects-valid Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: elpenguino+D gmail.com Example: ``` enum b = f(); int[4] f() { int[4] x = [1,2,3,4] * [1,2,3,4]; return x; } ``` f() works fine at runtime, but fails during CTFE with `Error: variable x cannot be read at compile time`. Looking at the -vcg-ast output, it becomes clear why: `int[4] x = arrayOp(x[], [1, 2, 3, 4], [1, 2, 3, 4]);`. The presence of x in that statement is illegal. --
Aug 02 2020