Skip to content

Commit 04637e2

Browse files
committed
patch 8.2.1606: Vim9: cannot use "true" with has()
Problem: Vim9: cannot use "true" with has(). Solution: Use tv_get_bool(). (closes #6876)
1 parent b02628b commit 04637e2

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/evalfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4763,7 +4763,7 @@ f_has(typval_T *argvars, typval_T *rettv)
47634763
}
47644764
}
47654765

4766-
if (argvars[1].v_type != VAR_UNKNOWN && tv_get_number(&argvars[1]) != 0)
4766+
if (argvars[1].v_type != VAR_UNKNOWN && tv_get_bool(&argvars[1]))
47674767
// return whether feature could ever be enabled
47684768
rettv->vval.v_number = x;
47694769
else

src/testdir/test_vim9_func.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,10 @@ def Test_getcompletion()
15161516
set wildignore&
15171517
enddef
15181518

1519+
def Test_has()
1520+
assert_equal(1, has('eval', true))
1521+
enddef
1522+
15191523
def Fibonacci(n: number): number
15201524
if n < 2
15211525
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+
1606,
757759
/**/
758760
1605,
759761
/**/

0 commit comments

Comments
 (0)