mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-08 16:48:18 +00:00
Fix comparison of two nil unions against each other
This commit is contained in:
+16
-1
@@ -241,8 +241,23 @@ gb_internal lbValue lb_equal_proc_for_type(lbModule *m, Type *type) {
|
||||
lb_emit_if(p, tag_eq, block_switch, block_false);
|
||||
|
||||
lb_start_block(p, block_switch);
|
||||
LLVMValueRef v_switch = LLVMBuildSwitch(p->builder, left_tag.value, block_false->block, cast(unsigned)type->Union.variants.count);
|
||||
|
||||
unsigned variant_count = cast(unsigned)type->Union.variants.count;
|
||||
if (type->Union.kind != UnionType_no_nil) {
|
||||
variant_count += 1;
|
||||
}
|
||||
LLVMValueRef v_switch = LLVMBuildSwitch(p->builder, left_tag.value, block_false->block, variant_count);
|
||||
|
||||
if (type->Union.kind != UnionType_no_nil) {
|
||||
lbBlock *case_block = lb_create_block(p, "bcase");
|
||||
lb_start_block(p, case_block);
|
||||
|
||||
lbValue case_tag = lb_const_int(p->module, union_tag_type(type), 0);
|
||||
|
||||
LLVMBuildRet(p->builder, LLVMConstInt(lb_type(m, t_bool), 1, false));
|
||||
|
||||
LLVMAddCase(v_switch, case_tag.value, case_block->block);
|
||||
}
|
||||
|
||||
for (Type *v : type->Union.variants) {
|
||||
lbBlock *case_block = lb_create_block(p, "bcase");
|
||||
|
||||
Reference in New Issue
Block a user