Skip to content

Commit 119f557

Browse files
committed
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)
1 parent 9d8bfae commit 119f557

4 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@ f_count(typval_T *argvars, typval_T *rettv)
21672167
int error = FALSE;
21682168

21692169
if (argvars[2].v_type != VAR_UNKNOWN)
2170-
ic = (int)tv_get_number_chk(&argvars[2], &error);
2170+
ic = (int)tv_get_bool_chk(&argvars[2], &error);
21712171

21722172
if (argvars[0].v_type == VAR_STRING)
21732173
{

src/testdir/test_vim9_func.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,11 @@ def Fibonacci(n: number): number
14921492
endif
14931493
enddef
14941494

1495+
def Test_count()
1496+
assert_equal(3, count('ABC ABC ABC', 'b', true))
1497+
assert_equal(0, count('ABC ABC ABC', 'b', false))
1498+
enddef
1499+
14951500
def Test_recursive_call()
14961501
assert_equal(6765, Fibonacci(20))
14971502
enddef

src/typval.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ tv_get_bool(typval_T *varp)
283283
tv_get_bool_chk(typval_T *varp, int *denote)
284284
{
285285
return tv_get_bool_or_number_chk(varp, denote, TRUE);
286-
287286
}
288287

289288
#ifdef FEAT_FLOAT

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1571,
757759
/**/
758760
1570,
759761
/**/

0 commit comments

Comments
 (0)