patch 8.2.1615: Vim9: cannot pass "true" to searchdecl()

Problem:    Vim9: cannot pass "true" to searchdecl().
Solution:   use tv_get_bool_chk(). (closes #6881)
This commit is contained in:
Bram Moolenaar
2020-09-05 21:35:16 +02:00
parent 597aaac9d2
commit 30788d3d37
3 changed files with 10 additions and 4 deletions

View File

@ -6876,8 +6876,8 @@ f_search(typval_T *argvars, typval_T *rettv)
static void
f_searchdecl(typval_T *argvars, typval_T *rettv)
{
int locally = 1;
int thisblock = 0;
int locally = TRUE;
int thisblock = FALSE;
int error = FALSE;
char_u *name;
@ -6886,9 +6886,9 @@ f_searchdecl(typval_T *argvars, typval_T *rettv)
name = tv_get_string_chk(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
{
locally = (int)tv_get_number_chk(&argvars[1], &error) == 0;
locally = !(int)tv_get_bool_chk(&argvars[1], &error);
if (!error && argvars[2].v_type != VAR_UNKNOWN)
thisblock = (int)tv_get_number_chk(&argvars[2], &error) != 0;
thisblock = (int)tv_get_bool_chk(&argvars[2], &error);
}
if (!error && name != NULL)
rettv->vval.v_number = find_decl(name, (int)STRLEN(name),

View File

@ -1547,6 +1547,10 @@ def Test_searchcount()
bwipe!
enddef
def Test_searchdecl()
assert_equal(1, searchdecl('blah', true, true))
enddef
def Fibonacci(n: number): number
if n < 2
return n

View File

@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1615,
/**/
1614,
/**/