mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.4530: making comparison with null work changes legacy behavior
Problem: Making comparison with null work changes legacy behavior. Solution: Only use the better comparison in Vim9 script. (closes #9910)
This commit is contained in:
@@ -181,6 +181,38 @@ func Test_loop_over_null_list()
|
|||||||
call v9.CheckScriptFailure(lines, 'E121: Undefined variable: null_list')
|
call v9.CheckScriptFailure(lines, 'E121: Undefined variable: null_list')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_compare_with_null()
|
||||||
|
let s:value = v:null
|
||||||
|
call assert_true(s:value == v:null)
|
||||||
|
let s:value = v:true
|
||||||
|
call assert_false(s:value == v:null)
|
||||||
|
let s:value = v:none
|
||||||
|
call assert_false(s:value == v:null)
|
||||||
|
let s:value = 0
|
||||||
|
call assert_true(s:value == v:null)
|
||||||
|
if has('float')
|
||||||
|
let s:value = 0.0
|
||||||
|
call assert_true(s:value == v:null)
|
||||||
|
endif
|
||||||
|
let s:value = ''
|
||||||
|
call assert_false(s:value == v:null)
|
||||||
|
let s:value = 0z
|
||||||
|
call assert_false(s:value == v:null)
|
||||||
|
let s:value = []
|
||||||
|
call assert_false(s:value == v:null)
|
||||||
|
let s:value = {}
|
||||||
|
call assert_false(s:value == v:null)
|
||||||
|
let s:value = function('len')
|
||||||
|
call assert_false(s:value == v:null)
|
||||||
|
if has('job')
|
||||||
|
let s:value = test_null_job()
|
||||||
|
call assert_true(s:value == v:null)
|
||||||
|
let s:value = test_null_channel()
|
||||||
|
call assert_true(s:value == v:null)
|
||||||
|
endif
|
||||||
|
unlet s:value
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_setreg_null_list()
|
func Test_setreg_null_list()
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
call setreg('x', test_null_list())
|
call setreg('x', test_null_list())
|
||||||
|
@@ -1381,7 +1381,7 @@ typval_compare_list(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compare v:null/v:none with another type. Return TRUE if the value is NULL.
|
* Compare v:null with another type. Return TRUE if the value is NULL.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
typval_compare_null(typval_T *tv1, typval_T *tv2)
|
typval_compare_null(typval_T *tv1, typval_T *tv2)
|
||||||
@@ -1417,6 +1417,9 @@ typval_compare_null(typval_T *tv1, typval_T *tv2)
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!in_vim9script())
|
||||||
|
return FALSE; // backwards compatible
|
||||||
|
|
||||||
semsg(_(e_cannot_compare_str_with_str),
|
semsg(_(e_cannot_compare_str_with_str),
|
||||||
vartype_name(tv1->v_type), vartype_name(tv2->v_type));
|
vartype_name(tv1->v_type), vartype_name(tv2->v_type));
|
||||||
return MAYBE;
|
return MAYBE;
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4530,
|
||||||
/**/
|
/**/
|
||||||
4529,
|
4529,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user