aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-11-16 10:06:58 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-11-16 10:06:58 -0500
commitf12d36641f67564d2103f75ed7a5445219197db5 (patch)
tree63f967ea88d81475466fbc00929e05d8fe1ec2a3 /src/codegen.cpp
parent018cbff438cedc19d0ad18021619ec7ede997307 (diff)
downloadzig-f12d36641f67564d2103f75ed7a5445219197db5.tar.gz
zig-f12d36641f67564d2103f75ed7a5445219197db5.zip
union secret field is the tag index instead of distinct type index
See #144
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp5
1 files changed, 2 insertions, 3 deletions
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;