authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-12-05 18:58:54+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-12-05 18:58:54+01:00
log0f7954831a881c899002eaf8c203aec35dedeeee
treea27c37018f35dad7c41bed39cc7b25fc8d3da8f2
parent865d6df03e20b3338bafb15c23bce6b5912ecf88

stage1: Initialize single-element union tag correctly

Use the field value instead of defaulting to zero.

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

src/stage1/analyze.cpp+1-1
...@@ -6113,7 +6113,7 @@ ZigValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry) {...@@ -6113,7 +6113,7 @@ ZigValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry) {
6113 TypeUnionField *only_field = &union_type->data.unionation.fields[0];6113 TypeUnionField *only_field = &union_type->data.unionation.fields[0];
6114 ZigType *field_type = resolve_union_field_type(g, only_field);6114 ZigType *field_type = resolve_union_field_type(g, only_field);
6115 assert(field_type);6115 assert(field_type);
6116 bigint_init_unsigned(&result->data.x_union.tag, 0);6116 bigint_init_bigint(&result->data.x_union.tag, &only_field->enum_field->value);
6117 result->data.x_union.payload = g->pass1_arena->create<ZigValue>();6117 result->data.x_union.payload = g->pass1_arena->create<ZigValue>();
6118 copy_const_val(g, result->data.x_union.payload,6118 copy_const_val(g, result->data.x_union.payload,
6119 get_the_one_possible_value(g, field_type));6119 get_the_one_possible_value(g, field_type));