changeset 22113:a71d7dcba862 v8.2.1606

patch 8.2.1606: Vim9: cannot use "true" with has() Commit: https://github.com/vim/vim/commit/04637e243d39f791cfc97c3ce96d99ef1bf047e1 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 5 18:45:29 2020 +0200 patch 8.2.1606: Vim9: cannot use "true" with has() Problem: Vim9: cannot use "true" with has(). Solution: Use tv_get_bool(). (closes https://github.com/vim/vim/issues/6876)
author Bram Moolenaar <Bram@vim.org>
date Sat, 05 Sep 2020 19:00:03 +0200
parents 0c20a211a4ef
children e3c12e8b91b0
files src/evalfunc.c src/testdir/test_vim9_func.vim src/version.c
diffstat 3 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -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
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -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
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1606,
+/**/
     1605,
 /**/
     1604,