diff options
| author | gingerBill <bill@gingerbill.org> | 2024-09-30 11:10:16 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-09-30 11:10:16 +0100 |
| commit | 225ffdec36c7e131cac8b10a68a45037307adc83 (patch) | |
| tree | 00d917a9c2c6b006b14e0a5607886599b81c6be1 /src/llvm_backend_expr.cpp | |
| parent | 7f9cfd15797427f654584960065be4b0a024d9d6 (diff) | |
Fix union comparison bug
Diffstat (limited to 'src/llvm_backend_expr.cpp')
| -rw-r--r-- | src/llvm_backend_expr.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index 608be4947..328237e25 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -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); |