diff src/vim9instr.c @ 32210:012facc8e25c v9.0.1436

patch 9.0.1436: cannot compare a typed variable with v:none Commit: https://github.com/vim/vim/commit/2ed57ac3675624b9d943d7753f48855e5dbebdbb Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 1 22:05:38 2023 +0100 patch 9.0.1436: cannot compare a typed variable with v:none Problem: Cannot compare a typed variable with v:none. Solution: Allow for "x is v:none" and "x isnot v:none". (issue https://github.com/vim/vim/issues/12194)
author Bram Moolenaar <Bram@vim.org>
date Sat, 01 Apr 2023 23:15:03 +0200
parents 76fd08a4ae1d
children b9a8d1c453e1
line wrap: on
line diff
--- a/src/vim9instr.c
+++ b/src/vim9instr.c
@@ -413,7 +413,7 @@ generate_two_op(cctx_T *cctx, char_u *op
  */
     static isntype_T
 get_compare_isn(
-	exprtype_T exprtype,
+	exprtype_T  exprtype,
 	typval_T    *tv1,
 	typval_T    *tv2,
 	type_T	    *type1,
@@ -485,13 +485,17 @@ get_compare_isn(
 	return ISN_DROP;
     }
     if (isntype == ISN_DROP
-	    || ((exprtype != EXPR_EQUAL && exprtype != EXPR_NEQUAL
-		    && (vartype1 == VAR_BOOL || vartype1 == VAR_SPECIAL
-		       || vartype2 == VAR_BOOL || vartype2 == VAR_SPECIAL)))
-	    || ((exprtype != EXPR_EQUAL && exprtype != EXPR_NEQUAL
-			       && exprtype != EXPR_IS && exprtype != EXPR_ISNOT
-		    && (vartype1 == VAR_BLOB || vartype2 == VAR_BLOB
-			|| vartype1 == VAR_LIST || vartype2 == VAR_LIST))))
+	    || (isntype != ISN_COMPARENULL
+		&& (((exprtype != EXPR_EQUAL
+			&& exprtype != EXPR_NEQUAL
+			&& (vartype1 == VAR_BOOL || vartype1 == VAR_SPECIAL
+			  || vartype2 == VAR_BOOL || vartype2 == VAR_SPECIAL)))
+		    || ((exprtype != EXPR_EQUAL
+			 && exprtype != EXPR_NEQUAL
+			 && exprtype != EXPR_IS
+			 && exprtype != EXPR_ISNOT
+			 && (vartype1 == VAR_BLOB || vartype2 == VAR_BLOB
+			  || vartype1 == VAR_LIST || vartype2 == VAR_LIST))))))
     {
 	semsg(_(e_cannot_compare_str_with_str),
 		vartype_name(vartype1), vartype_name(vartype2));