patch 8.2.1576: Vim9: index() does not take "true" as argument
Problem: Vim9: index() does not take "true" as argument.
Solution: Use tv_get_bool_chk(). (closes #6823)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 340ecf0..4f0bb5c 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -4944,7 +4944,7 @@
item = list_find(l, (long)tv_get_number_chk(&argvars[2], &error));
idx = l->lv_u.mat.lv_idx;
if (argvars[3].v_type != VAR_UNKNOWN)
- ic = (int)tv_get_number_chk(&argvars[3], &error);
+ ic = (int)tv_get_bool_chk(&argvars[3], &error);
if (error)
item = NULL;
}
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 11a6ddd..04f8d7a 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1497,6 +1497,10 @@
assert_equal(0, count('ABC ABC ABC', 'b', false))
enddef
+def Test_index()
+ assert_equal(3, index(['a', 'b', 'a', 'B'], 'b', 2, true))
+enddef
+
def Test_expand()
split SomeFile
assert_equal(['SomeFile'], expand('%', true, true))
diff --git a/src/version.c b/src/version.c
index 2bf4914..388be57 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1576,
+/**/
1575,
/**/
1574,