From 225ffdec36c7e131cac8b10a68a45037307adc83 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 30 Sep 2024 11:10:16 +0100 Subject: [PATCH] Fix union comparison bug --- src/llvm_backend_expr.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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);