Merge pull request #7039 from Znarf64/fix_subtype_comparisons

Fix subtype comparisons
This commit is contained in:
gingerBill
2026-07-14 13:54:35 +01:00
committed by GitHub

View File

@@ -3409,8 +3409,11 @@ gb_internal lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left
i64 ls = type_size_of(lt);
i64 rs = type_size_of(rt);
// NOTE(bill): Quick heuristic, larger types are usually the target type
if (ls < rs) {
if (check_is_assignable_to_using_subtype(lt, rt)) {
left = lb_emit_conv(p, left, rt);
} else if (check_is_assignable_to_using_subtype(rt, lt)) {
right = lb_emit_conv(p, right, lt);
} else if (ls < rs) { // NOTE(bill): Quick heuristic, larger types are usually the target type
left = lb_emit_conv(p, left, rt);
} else if (ls > rs) {
right = lb_emit_conv(p, right, lt);
@@ -4078,7 +4081,7 @@ gb_internal lbValue lb_emit_comp_against_nil(lbProcedure *p, TokenKind op_kind,
return res;
}
}
} else if (is_type_struct(t) && type_has_nil(t)) {
} else if (is_type_struct(t)) {
auto args = array_make<lbValue>(permanent_allocator(), 2);
lbValue lhs = lb_address_from_load_or_generate_local(p, x);
args[0] = lb_emit_conv(p, lhs, t_rawptr);