[Issue 24634] CTFE on static arrays with StructInitializers fails to compile
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jun 27 12:33:36 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24634
basile-z <b2.temp at gmx.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|CTFE |
Status|NEW |RESOLVED
Hardware|x86 |All
Resolution|--- |INVALID
OS|Mac OS X |All
--- Comment #1 from basile-z <b2.temp at gmx.com> ---
That's not really a bug. The problem is that StructInitializer is not supported
when the variable initializer is an AssignExpression. You can verify that in
the specifications: https://dlang.org/spec/declaration.html#initialization:
```
auto A[1] as = [{0}];
```
takes the path of ArrayLiteral. ArrayLiteral supports StructInitializer.
```
auto A[1] as = [{0}].update();
```
takes the path of AssignExpression. AssignExpression dont support
StructInitializer.
As a workaround you can decompose
```
auto A[1] as0 = [{0}];
auto A[1] as1 = [{0}].update();
```
--
More information about the Digitalmars-d-bugs
mailing list