aboutsummaryrefslogtreecommitdiff
path: root/src/stage1/analyze.cpp
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2020-12-05 18:58:54 +0100
committerLemonBoy <thatlemon@gmail.com>2020-12-05 18:58:54 +0100
commit0f7954831a881c899002eaf8c203aec35dedeeee (patch)
treea27c37018f35dad7c41bed39cc7b25fc8d3da8f2 /src/stage1/analyze.cpp
parent865d6df03e20b3338bafb15c23bce6b5912ecf88 (diff)
downloadzig-0f7954831a881c899002eaf8c203aec35dedeeee.tar.gz
zig-0f7954831a881c899002eaf8c203aec35dedeeee.zip
stage1: Initialize single-element union tag correctly
Use the field value instead of defaulting to zero.
Diffstat (limited to 'src/stage1/analyze.cpp')
-rw-r--r--src/stage1/analyze.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/stage1/analyze.cpp b/src/stage1/analyze.cpp
index 5b0ea53eb4..e8958052bc 100644
--- a/src/stage1/analyze.cpp
+++ b/src/stage1/analyze.cpp
@@ -6113,7 +6113,7 @@ ZigValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry) {
TypeUnionField *only_field = &union_type->data.unionation.fields[0];
ZigType *field_type = resolve_union_field_type(g, only_field);
assert(field_type);
- bigint_init_unsigned(&result->data.x_union.tag, 0);
+ bigint_init_bigint(&result->data.x_union.tag, &only_field->enum_field->value);
result->data.x_union.payload = g->pass1_arena->create<ZigValue>();
copy_const_val(g, result->data.x_union.payload,
get_the_one_possible_value(g, field_type));