Skip to content

Commit 30788d3

Browse files
committed
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)
1 parent 597aaac commit 30788d3

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/evalfunc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6876,8 +6876,8 @@ f_search(typval_T *argvars, typval_T *rettv)
68766876
static void
68776877
f_searchdecl(typval_T *argvars, typval_T *rettv)
68786878
{
6879-
int locally = 1;
6880-
int thisblock = 0;
6879+
int locally = TRUE;
6880+
int thisblock = FALSE;
68816881
int error = FALSE;
68826882
char_u *name;
68836883

@@ -6886,9 +6886,9 @@ f_searchdecl(typval_T *argvars, typval_T *rettv)
68866886
name = tv_get_string_chk(&argvars[0]);
68876887
if (argvars[1].v_type != VAR_UNKNOWN)
68886888
{
6889-
locally = (int)tv_get_number_chk(&argvars[1], &error) == 0;
6889+
locally = !(int)tv_get_bool_chk(&argvars[1], &error);
68906890
if (!error && argvars[2].v_type != VAR_UNKNOWN)
6891-
thisblock = (int)tv_get_number_chk(&argvars[2], &error) != 0;
6891+
thisblock = (int)tv_get_bool_chk(&argvars[2], &error);
68926892
}
68936893
if (!error && name != NULL)
68946894
rettv->vval.v_number = find_decl(name, (int)STRLEN(name),

src/testdir/test_vim9_func.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,10 @@ def Test_searchcount()
15471547
bwipe!
15481548
enddef
15491549

1550+
def Test_searchdecl()
1551+
assert_equal(1, searchdecl('blah', true, true))
1552+
enddef
1553+
15501554
def Fibonacci(n: number): number
15511555
if n < 2
15521556
return n

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1615,
757759
/**/
758760
1614,
759761
/**/

0 commit comments

Comments
 (0)