Skip to content

Commit

Permalink
patch 8.2.4489: failing test for comparing v:null with number
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brammool committed Mar 2, 2022
1 parent f6b0c79 commit c6e9d70
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/testdir/test_vimscript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions src/typval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,15 @@ typval_compare_null(typval_T *tv1, typval_T *tv2)
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;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4489,
/**/
4488,
/**/
Expand Down

0 comments on commit c6e9d70

Please sign in to comment.