From: Bram Moolenaar Date: Sat, 5 Sep 2020 19:35:16 +0000 (+0200) Subject: patch 8.2.1615: Vim9: cannot pass "true" to searchdecl() X-Git-Tag: v8.2.1615 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30788d3d37a90b0702d94b7272ed26672534ba6f;p=vim 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) --- diff --git a/src/evalfunc.c b/src/evalfunc.c index 2a8281230..e74a82a91 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -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), diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 6aa9f365a..24377b289 100644 --- 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 index 750e2874a..0cce5b232 100644 --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1615, /**/ 1614, /**/