Allow designated initialization of struct
ryuukk_
ryuukk.dev at gmail.com
Thu Sep 12 12:14:17 UTC 2024
Today i tried this:
```D
struct Test
{
int test;
}
struct Data
{
Test[8] test;
}
void add(Data data)
{
}
extern(C) void main()
{
add( Data(test: [ {test: 1}] ) );
}
```
it refuses to compile:
```
onlineapp.d(19): Error: found `}` when expecting `;` following
expression
onlineapp.d(19): expression: `1`
onlineapp.d(19): Error: found `]` instead of statement
onlineapp.d(21): Error: found `End of File` when expecting `,`
onlineapp.d(19): Error: found `End of File` when expecting `]`
onlineapp.d(21): Error: found `End of File` when expecting `)`
onlineapp.d(21): Error: found `End of File` when expecting `)`
onlineapp.d(21): Error: found `End of File` when expecting `;`
following expression
onlineapp.d(19): expression: `add(Data(test: [()
{
test:
1;
__error__
}
]))`
onlineapp.d(21): Error: matching `}` expected following compound
statement, not `End of File`
onlineapp.d(18): unmatched `{`
```
D worse than C with these stupid RAII, give me proper way to
initialize a struct instead of giving me a broken constructor i'm
not even using
More information about the dip.ideas
mailing list