Ignore const nil "optimization" and fix c: Maybe(string); c == "" bug.

This commit is contained in:
gingerBill
2026-02-24 18:52:42 +00:00
parent 1e1e00c68e
commit c0468446f6
2 changed files with 10 additions and 2 deletions

View File

@@ -7421,6 +7421,8 @@ gb_internal CallArgumentData check_call_arguments_proc_group(CheckerContext *c,
spaces[max_spaces] = 0;
{
// TODO(bill): This is absolutely awful code, that needs improving a lot
bool try_addr = false;
isize try_addr_idx = -1;

View File

@@ -2971,6 +2971,7 @@ gb_internal lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left
return nil_check;
}
if (are_types_identical(a, b)) {
// NOTE(bill): No need for a conversion
} else if ((lb_is_const(left) && !is_type_array(left.type)) || lb_is_const_nil(left)) {
@@ -2983,15 +2984,20 @@ gb_internal lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue 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);
if (LLVMTypeOf(left.value) == LLVMTypeOf(right.value)) {
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);
if (LLVMTypeOf(left.value) == LLVMTypeOf(right.value)) {
return lb_emit_comp_against_nil(p, op_kind, left);
}
}
right = lb_emit_conv(p, right, left.type);
} else {