mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Fix for crash when emitting a comparison between a constant array and a non-constant value.
This commit is contained in:
@@ -2555,17 +2555,21 @@ gb_internal lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left
|
|||||||
|
|
||||||
if (are_types_identical(a, b)) {
|
if (are_types_identical(a, b)) {
|
||||||
// NOTE(bill): No need for a conversion
|
// NOTE(bill): No need for a conversion
|
||||||
} else if (lb_is_const(left) || lb_is_const_nil(left)) {
|
} else if ((lb_is_const(left) && !is_type_array(left.type)) || lb_is_const_nil(left)) {
|
||||||
|
// NOTE(karl): !is_type_array(left.type) is there to avoid lb_emit_conv
|
||||||
|
// trying to convert a constant array into a non-array. In that case we
|
||||||
|
// want the `else` branch to happen, so it can try to convert the
|
||||||
|
// non-array into an array instead.
|
||||||
|
|
||||||
if (lb_is_const_nil(left)) {
|
if (lb_is_const_nil(left)) {
|
||||||
return lb_emit_comp_against_nil(p, op_kind, right);
|
return lb_emit_comp_against_nil(p, op_kind, right);
|
||||||
}
|
}
|
||||||
left = lb_emit_conv(p, left, right.type);
|
left = lb_emit_conv(p, left, right.type);
|
||||||
} else if (lb_is_const(right) || lb_is_const_nil(right)) {
|
} else if ((lb_is_const(right) && !is_type_array(right.type)) || lb_is_const_nil(right)) {
|
||||||
if (lb_is_const_nil(right)) {
|
if (lb_is_const_nil(right)) {
|
||||||
return lb_emit_comp_against_nil(p, op_kind, left);
|
return lb_emit_comp_against_nil(p, op_kind, left);
|
||||||
}
|
}
|
||||||
right = lb_emit_conv(p, right, left.type);
|
right = lb_emit_conv(p, right, left.type);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Type *lt = left.type;
|
Type *lt = left.type;
|
||||||
Type *rt = right.type;
|
Type *rt = right.type;
|
||||||
|
|||||||
Reference in New Issue
Block a user