[Issue 24634] New: CTFE on static arrays with StructInitializers fails to compile
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 26 22:30:43 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24634
Issue ID: 24634
Summary: CTFE on static arrays with StructInitializers fails to
compile
Product: D
Version: D2
Hardware: x86
OS: Mac OS X
Status: NEW
Keywords: CTFE
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: mail at tomaskral.sk
Compiling the following code fails with:
Error: found `}` when expecting `;` following expression
```
struct A { int val; }
enum A[2] as = [{0}, {1}].update;
auto update(A[] as) {
foreach (ref a; as) a.val++;
return as;
}
```
Interestingly, if I replace struct initializers with struct ctors, e.g.:
```
enum A[2] as = [A(0), A(1)].update;
```
the code compiles just fine.
--
More information about the Digitalmars-d-bugs
mailing list