Ver código fonte

Fix union comparison bug

gingerBill 10 meses atrás
pai
commit
225ffdec36
1 arquivos alterados com 6 adições e 0 exclusões
  1. 6 0
      src/llvm_backend_expr.cpp

+ 6 - 0
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);