changeset 27928:ca7a207d83cd v8.2.4489

patch 8.2.4489: failing test for comparing v:null with number Commit: https://github.com/vim/vim/commit/c6e9d7063d275139d3c207435d293271c8b556ab Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 2 13:13:30 2022 +0000 patch 8.2.4489: failing test for comparing v:null with number Problem: Failing test for comparing v:null with number. Solution: Allow comparing v:null with number in legacy script. (Ken Takata, closes #9873) Also do this for float.
author Bram Moolenaar <Bram@vim.org>
date Wed, 02 Mar 2022 14:15:04 +0100
parents 45b66f615f24
children 71f8bb3b8224
files src/testdir/test_vimscript.vim src/typval.c src/version.c
diffstat 3 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vimscript.vim
+++ b/src/testdir/test_vimscript.vim
@@ -6546,9 +6546,16 @@ func Test_type()
     call assert_true(v:true != v:false)
 
     call assert_true(v:null == 0)
+    call assert_false(v:null == 1)
     call assert_false(v:null != 0)
     call assert_true(v:none == 0)
+    call assert_false(v:none == 1)
     call assert_false(v:none != 0)
+    if has('float')
+      call assert_true(v:null == 0.0)
+      call assert_false(v:null == 0.1)
+      call assert_false(v:null != 0.0)
+    endif
 
     call assert_true(v:false is v:false)
     call assert_true(v:true is v:true)
--- a/src/typval.c
+++ b/src/typval.c
@@ -1405,6 +1405,15 @@ typval_compare_null(typval_T *tv1, typva
 	    case VAR_LIST: return tv->vval.v_list == NULL;
 	    case VAR_PARTIAL: return tv->vval.v_partial == NULL;
 	    case VAR_STRING: return tv->vval.v_string == NULL;
+
+	    case VAR_NUMBER: if (!in_vim9script())
+				 return tv->vval.v_number == 0;
+			     break;
+#ifdef FEAT_FLOAT
+	    case VAR_FLOAT: if (!in_vim9script())
+				 return tv->vval.v_float == 0.0;
+			     break;
+#endif
 	    default: break;
 	}
     }
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4489,
+/**/
     4488,
 /**/
     4487,