Struct initialization extra comma - should it compile
Bastiaan Veelo
Bastiaan at Veelo.net
Sun Apr 25 14:28:49 UTC 2021
On Sunday, 25 April 2021 at 13:39:54 UTC, JN wrote:
> struct Foo
> {
> int x, y, z;
> }
>
> void main()
> {
> Foo bar = Foo(1,);
> }
>
> This compiles without syntax errors, is this expected?
Yes, the
[specification](https://dlang.org/spec/declaration.html#StructInitializer) is like this:
```
StructMemberInitializers:
StructMemberInitializer
StructMemberInitializer ,
StructMemberInitializer , StructMemberInitializers
```
— Bastiaan.
More information about the Digitalmars-d-learn
mailing list