# HG changeset patch # User Bram Moolenaar # Date 1599335103 -7200 # Node ID bd3541849208d6dc10d661ecc8e027cc9a6d9e5e # Parent 2b7c85de5c77145ad614a3fd338bf011a6f34080 patch 8.2.1615: Vim9: cannot pass "true" to searchdecl() Commit: https://github.com/vim/vim/commit/30788d3d37a90b0702d94b7272ed26672534ba6f Author: Bram Moolenaar Date: Sat Sep 5 21:35:16 2020 +0200 patch 8.2.1615: Vim9: cannot pass "true" to searchdecl() Problem: Vim9: cannot pass "true" to searchdecl(). Solution: use tv_get_bool_chk(). (closes https://github.com/vim/vim/issues/6881) diff --git a/src/evalfunc.c b/src/evalfunc.c --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -6876,8 +6876,8 @@ f_search(typval_T *argvars, typval_T *re 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 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), diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -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 diff --git a/src/version.c b/src/version.c --- 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 */ /**/ + 1615, +/**/ 1614, /**/ 1613,