From f12d36641f67564d2103f75ed7a5445219197db5 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 16 Nov 2017 10:06:58 -0500 Subject: union secret field is the tag index instead of distinct type index See #144 --- src/codegen.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 26a2590e44..3777c3a87a 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3962,7 +3962,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) { case TypeTableEntryIdUnion: { LLVMTypeRef union_type_ref = type_entry->data.unionation.union_type_ref; - ConstExprValue *payload_value = const_val->data.x_union.value; + ConstExprValue *payload_value = const_val->data.x_union.payload; assert(payload_value != nullptr); if (!type_has_bits(payload_value->type)) { @@ -3999,8 +3999,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) { return union_value_ref; } - size_t distinct_type_index = type_entry->data.unionation.distinct_types.get(const_val->data.x_union.value->type); - LLVMValueRef tag_value = LLVMConstInt(type_entry->data.unionation.tag_type->type_ref, distinct_type_index, false); + LLVMValueRef tag_value = LLVMConstInt(type_entry->data.unionation.tag_type->type_ref, const_val->data.x_union.tag, false); LLVMValueRef fields[2]; fields[type_entry->data.unionation.gen_union_index] = union_value_ref; -- cgit v1.2.3