]> granicus.if.org Git - vim/commitdiff
patch 8.2.1571: Vim9: count() third argument cannot be "true" v8.2.1571
authorBram Moolenaar <Bram@vim.org>
Wed, 2 Sep 2020 19:31:22 +0000 (21:31 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 2 Sep 2020 19:31:22 +0000 (21:31 +0200)
Problem:    Vim9: count() third argument cannot be "true".
Solution:   use tv_get_bool_chk(). (closes #6818)

src/list.c
src/testdir/test_vim9_func.vim
src/typval.c
src/version.c

index e7d288a2fb4cfb80ea2bad3fc6fcda16bc1e3ca3..e0c8c2e17d254900955f8ab96d175591423345bb 100644 (file)
@@ -2167,7 +2167,7 @@ f_count(typval_T *argvars, typval_T *rettv)
     int                error = FALSE;
 
     if (argvars[2].v_type != VAR_UNKNOWN)
-       ic = (int)tv_get_number_chk(&argvars[2], &error);
+       ic = (int)tv_get_bool_chk(&argvars[2], &error);
 
     if (argvars[0].v_type == VAR_STRING)
     {
index 480a9a5a7d8270d5215fb3e73995d3b4b7652cc4..8f4928ac0e3c742005bfde882ecf499aa14cda0a 100644 (file)
@@ -1492,6 +1492,11 @@ def Fibonacci(n: number): number
   endif
 enddef
 
+def Test_count()
+  assert_equal(3, count('ABC ABC ABC', 'b', true))
+  assert_equal(0, count('ABC ABC ABC', 'b', false))
+enddef
+
 def Test_recursive_call()
   assert_equal(6765, Fibonacci(20))
 enddef
index c7cfd411672011ee169a2bd73c33c8233f9d8a75..db52d597308335effacd53826d26e6c464abff4d 100644 (file)
@@ -283,7 +283,6 @@ tv_get_bool(typval_T *varp)
 tv_get_bool_chk(typval_T *varp, int *denote)
 {
     return tv_get_bool_or_number_chk(varp, denote, TRUE);
-
 }
 
 #ifdef FEAT_FLOAT
index 6b4c1cd2733136b71868ad74498c58257a696027..9399221cd5627f1733d810c8e9358e9981ef299c 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1571,
 /**/
     1570,
 /**/