stage2 astgen: fix bug in struct init where type not refed

This commit is contained in:
Jacob G-W 2021-06-08 22:05:03 -04:00 committed by Andrew Kelley
parent 75f7a8913e
commit 2092481265

View File

@ -1328,6 +1328,8 @@ fn structInitExpr(
}
switch (rl) {
.discard => {
if (struct_init.ast.type_expr != 0)
_ = try typeExpr(gz, scope, struct_init.ast.type_expr);
for (struct_init.ast.fields) |field_init| {
_ = try expr(gz, scope, .discard, field_init);
}
@ -1412,6 +1414,9 @@ fn structInitExprRlPtr(
const field_ptr_list = try gpa.alloc(Zir.Inst.Index, struct_init.ast.fields.len);
defer gpa.free(field_ptr_list);
if (struct_init.ast.type_expr != 0)
_ = try typeExpr(gz, scope, struct_init.ast.type_expr);
for (struct_init.ast.fields) |field_init, i| {
const name_token = tree.firstToken(field_init) - 2;
const str_index = try astgen.identAsString(name_token);