On Thursday, 12 September 2024 at 12:14:17 UTC, ryuukk_ wrote:
>struct Test
{
int test;
}
struct Data
{
Test[8] test;
}
void add(Data data)
{
}
extern(C) void main()
{
add( Data(test: [ {test: 1}] ) );
}
You are passing a struct literal to add
. A struct literal is an expression:
https://dlang.org/spec/struct.html#struct-literal
A struct literal consists of the name of the struct followed by a parenthesized named argument list
So [ {test: 1}]
is parsed as an array literal (because it is an expression), not an array intializer. {test: 1}
in expression context is parsed as an invalid function literal (because there's no semi-colon).