diff src/vim9execute.c @ 27924:e6e3abc28c7a v8.2.4487

patch 8.2.4487: Vim9: cannot compare with v:null Commit: https://github.com/vim/vim/commit/7a2222487507eb13cccdb9a66397092775d62b8c Author: Bram Moolenaar <Bram@vim.org> Date: Tue Mar 1 19:23:24 2022 +0000 patch 8.2.4487: Vim9: cannot compare with v:null Problem: Vim9: cannot compare with v:null. Solution: Allow comparing anything with v:null. (closes https://github.com/vim/vim/issues/9866)
author Bram Moolenaar <Bram@vim.org>
date Tue, 01 Mar 2022 20:30:04 +0100
parents 7d70b420de00
children 1012048eed26
line wrap: on
line diff
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -3880,6 +3880,25 @@ exec_instructions(ectx_T *ectx)
 		}
 		break;
 
+	    case ISN_COMPARENULL:
+		{
+		    typval_T	*tv1 = STACK_TV_BOT(-2);
+		    typval_T	*tv2 = STACK_TV_BOT(-1);
+		    int		res;
+
+		    res = typval_compare_null(tv1, tv2);
+		    if (res == MAYBE)
+			goto on_error;
+		    if (iptr->isn_arg.op.op_type == EXPR_NEQUAL)
+			res = !res;
+		    clear_tv(tv1);
+		    clear_tv(tv2);
+		    --ectx->ec_stack.ga_len;
+		    tv1->v_type = VAR_BOOL;
+		    tv1->vval.v_number = res ? VVAL_TRUE : VVAL_FALSE;
+		}
+		break;
+
 	    // Operation with two number arguments
 	    case ISN_OPNR:
 	    case ISN_COMPARENR:
@@ -5901,6 +5920,7 @@ list_instructions(char *pfx, isn_T *inst
 
 	    case ISN_COMPAREBOOL:
 	    case ISN_COMPARESPECIAL:
+	    case ISN_COMPARENULL:
 	    case ISN_COMPARENR:
 	    case ISN_COMPAREFLOAT:
 	    case ISN_COMPARESTRING:
@@ -5936,6 +5956,7 @@ list_instructions(char *pfx, isn_T *inst
 			   case ISN_COMPAREBOOL: type = "COMPAREBOOL"; break;
 			   case ISN_COMPARESPECIAL:
 						 type = "COMPARESPECIAL"; break;
+			   case ISN_COMPARENULL: type = "COMPARENULL"; break;
 			   case ISN_COMPARENR: type = "COMPARENR"; break;
 			   case ISN_COMPAREFLOAT: type = "COMPAREFLOAT"; break;
 			   case ISN_COMPARESTRING: