[Issue 21104] New: certain array operations fail during CTFE when used to initialize a static array
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 2 20:55:21 UTC 2020
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 at puremagic.com
Reporter: elpenguino+D at 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.
--
More information about the Digitalmars-d-bugs
mailing list