1
0
forked from aniani/vim

patch 8.2.1571: Vim9: count() third argument cannot be "true"

Problem:    Vim9: count() third argument cannot be "true".
Solution:   use tv_get_bool_chk(). (closes #6818)
This commit is contained in:
Bram Moolenaar
2020-09-02 21:31:22 +02:00
parent 9d8bfae50f
commit 119f557230
4 changed files with 8 additions and 2 deletions

View File

@@ -2167,7 +2167,7 @@ f_count(typval_T *argvars, typval_T *rettv)
int error = FALSE; int error = FALSE;
if (argvars[2].v_type != VAR_UNKNOWN) 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) if (argvars[0].v_type == VAR_STRING)
{ {

View File

@@ -1492,6 +1492,11 @@ def Fibonacci(n: number): number
endif endif
enddef 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() def Test_recursive_call()
assert_equal(6765, Fibonacci(20)) assert_equal(6765, Fibonacci(20))
enddef enddef

View File

@@ -283,7 +283,6 @@ tv_get_bool(typval_T *varp)
tv_get_bool_chk(typval_T *varp, int *denote) tv_get_bool_chk(typval_T *varp, int *denote)
{ {
return tv_get_bool_or_number_chk(varp, denote, TRUE); return tv_get_bool_or_number_chk(varp, denote, TRUE);
} }
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1571,
/**/ /**/
1570, 1570,
/**/ /**/