]> granicus.if.org Git - vim/commitdiff
patch 8.2.1606: Vim9: cannot use "true" with has() v8.2.1606
authorBram Moolenaar <Bram@vim.org>
Sat, 5 Sep 2020 16:45:29 +0000 (18:45 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 5 Sep 2020 16:45:29 +0000 (18:45 +0200)
Problem:    Vim9: cannot use "true" with has().
Solution:   Use tv_get_bool(). (closes #6876)

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

index aefb1bf4b14ea34648a03c8fbf0fa987cb72792b..9e384da4944dc076eccfa9856c898644d005d72e 100644 (file)
@@ -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
index eb608c51e8c26160802f2448a95a7a4d25422346..dcc8087f4d73a0860bea23dacc097a1671db7067 100644 (file)
@@ -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
index 69aececd0f0204a043ba3660c1d5b1d1a4ddad5a..70f736d15e5f8d26207f93151171d0d71f52cf9a 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1606,
 /**/
     1605,
 /**/