Skip to content

Commit

Permalink
patch 8.2.1606: Vim9: cannot use "true" with has()
Browse files Browse the repository at this point in the history
Problem:    Vim9: cannot use "true" with has().
Solution:   Use tv_get_bool(). (closes #6876)
  • Loading branch information
brammool committed Sep 5, 2020
1 parent b02628b commit 04637e2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/evalfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4763,7 +4763,7 @@ f_has(typval_T *argvars, typval_T *rettv)
}
}

if (argvars[1].v_type != VAR_UNKNOWN && tv_get_number(&argvars[1]) != 0)
if (argvars[1].v_type != VAR_UNKNOWN && tv_get_bool(&argvars[1]))
// return whether feature could ever be enabled
rettv->vval.v_number = x;
else
Expand Down
4 changes: 4 additions & 0 deletions src/testdir/test_vim9_func.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,10 @@ def Test_getcompletion()
set wildignore&
enddef

def Test_has()
assert_equal(1, has('eval', true))
enddef

def Fibonacci(n: number): number
if n < 2
return n
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1606,
/**/
1605,
/**/
Expand Down

0 comments on commit 04637e2

Please sign in to comment.