summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-09-02 21:31:22 +0200
committerBram Moolenaar <Bram@vim.org>2020-09-02 21:31:22 +0200
commit119f5572306c4abba91eaf446c0c52637db223e8 (patch)
treef927e1a1119ef2a22a6fc51c54ad0113d08741f9
parent9d8bfae50fdaf5f5ec6307c60ebd1fad0927c6be (diff)
patch 8.2.1571: Vim9: count() third argument cannot be "true"v8.2.1571
Problem: Vim9: count() third argument cannot be "true". Solution: use tv_get_bool_chk(). (closes #6818)
-rw-r--r--src/list.c2
-rw-r--r--src/testdir/test_vim9_func.vim5
-rw-r--r--src/typval.c1
-rw-r--r--src/version.c2
4 files changed, 8 insertions, 2 deletions
diff --git a/src/list.c b/src/list.c
index e7d288a2fb..e0c8c2e17d 100644
--- a/src/list.c
+++ b/src/list.c
@@ -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)
{
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 480a9a5a7d..8f4928ac0e 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -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
diff --git a/src/typval.c b/src/typval.c
index c7cfd41167..db52d59730 100644
--- a/src/typval.c
+++ b/src/typval.c
@@ -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
diff --git a/src/version.c b/src/version.c
index 6b4c1cd273..9399221cd5 100644
--- 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 */
/**/
+ 1571,
+/**/
1570,
/**/
1569,