authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-11-25 22:13:40+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-11-26 10:49:47-08:00
log21c488ce68480d5298fc51f80f2c854d4ec8c364
tree25f476910193cd8a0c7de25ef2fdec392ca091f7
parent58365c4e79479157bb0b4c2d66ad96c9a394651d

stage1: Force union member types to be resolved

No test case because I couldn't reduce the huuuge test case. Fixes the problem discovered by @ifreund.

1 files changed, 23 insertions(+), 1 deletions(-)

src/stage1/analyze.cpp+23-1
......@@ -3539,7 +3539,29 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {
35393539 union_type->abi_size = SIZE_MAX;
35403540 union_type->size_in_bits = SIZE_MAX;
35413541 }
3542 union_type->data.unionation.resolve_status = zero_bits ? ResolveStatusSizeKnown : ResolveStatusZeroBitsKnown;
3542
3543 if (zero_bits) {
3544 // Don't forget to resolve the types for each union member even though
3545 // the type is zero sized.
3546 // XXX: Do it in a nicer way in stage2.
3547 union_type->data.unionation.resolve_loop_flag_other = true;
3548
3549 for (uint32_t i = 0; i < field_count; i += 1) {
3550 TypeUnionField *union_field = &union_type->data.unionation.fields[i];
3551 ZigType *field_type = resolve_union_field_type(g, union_field);
3552 if (field_type == nullptr) {
3553 union_type->data.unionation.resolve_status = ResolveStatusInvalid;
3554 return ErrorSemanticAnalyzeFail;
3555 }
3556 }
3557
3558 union_type->data.unionation.resolve_loop_flag_other = false;
3559 union_type->data.unionation.resolve_status = ResolveStatusSizeKnown;
3560
3561 return ErrorNone;
3562 }
3563
3564 union_type->data.unionation.resolve_status = ResolveStatusZeroBitsKnown;
35433565
35443566 return ErrorNone;
35453567}