Fix union comparison bug

This commit is contained in:
gingerBill
2024-09-30 11:10:16 +01:00
parent 7f9cfd1579
commit 225ffdec36

View File

@@ -2562,11 +2562,17 @@ gb_internal lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left
// non-array into an array instead.
if (lb_is_const_nil(left)) {
if (internal_check_is_assignable_to(right.type, left.type)) {
right = lb_emit_conv(p, right, left.type);
}
return lb_emit_comp_against_nil(p, op_kind, right);
}
left = lb_emit_conv(p, left, right.type);
} else if ((lb_is_const(right) && !is_type_array(right.type)) || lb_is_const_nil(right)) {
if (lb_is_const_nil(right)) {
if (internal_check_is_assignable_to(left.type, right.type)) {
left = lb_emit_conv(p, left, right.type);
}
return lb_emit_comp_against_nil(p, op_kind, left);
}
right = lb_emit_conv(p, right, left.type);