]> granicus.if.org Git - vim/commitdiff
patch 8.2.1615: Vim9: cannot pass "true" to searchdecl() v8.2.1615
authorBram Moolenaar <Bram@vim.org>
Sat, 5 Sep 2020 19:35:16 +0000 (21:35 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 5 Sep 2020 19:35:16 +0000 (21:35 +0200)
Problem:    Vim9: cannot pass "true" to searchdecl().
Solution:   use tv_get_bool_chk(). (closes #6881)

src/evalfunc.c
src/testdir/test_vim9_func.vim
src/version.c

index 2a8281230ee91339a19dc2dbe6ea04f13e30a5f3..e74a82a91f90b0f7b011998194827f9f6a38500a 100644 (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),
index 6aa9f365aff67bb8f95f3a8d151b9d565635dc9f..24377b2898faea46988f20428fbc8650c0aaba40 100644 (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
index 750e2874aef517d912ff4f7b487034e52af74b95..0cce5b232e06d29aed2be4e72bcd989b24ccc788 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1615,
 /**/
     1614,
 /**/