Fix #21210 - ImportC: Initializing struct containing array with = {0} fails (#21211)

Fixes https://github.com/dlang/dmd/issues/21210
This commit is contained in:
drpriver 2025-04-12 04:17:24 -07:00 committed by GitHub
parent ce6cef9762
commit d66ef6a26d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 2 deletions

View file

@ -761,9 +761,13 @@ Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedIn
// C11 6.2.5-20 "element type shall be complete whenever the array type is specified"
assert(0); // should have been detected by parser
}
auto bt = tsa.nextOf().toBasetype();
auto tnsa = tsa.nextOf().toBasetype().isTypeSArray();
if (auto tnss = bt.isTypeStruct())
{
return subStruct(tnss, index);
}
auto tnsa = bt.isTypeSArray();
auto ai = new ArrayInitializer(ci.loc);
ai.isCarray = true;