patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Problem: Vim9: runtime and compile time type checks are not the same.
Solution: Add more runtime type checks for builtin functions. (Yegappan
Lakshmanan, closes #8646)
diff --git a/src/match.c b/src/match.c
index 8bb8ccc..b5762fc 100644
--- a/src/match.c
+++ b/src/match.c
@@ -959,8 +959,12 @@
f_clearmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
#ifdef FEAT_SEARCH_EXTRA
- win_T *win = get_optional_window(argvars, 0);
+ win_T *win;
+ if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL)
+ return;
+
+ win = get_optional_window(argvars, 0);
if (win != NULL)
clear_matches(win);
#endif
@@ -976,8 +980,12 @@
dict_T *dict;
matchitem_T *cur;
int i;
- win_T *win = get_optional_window(argvars, 0);
+ win_T *win;
+ if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL)
+ return;
+
+ win = get_optional_window(argvars, 0);
if (rettv_list_alloc(rettv) == FAIL || win == NULL)
return;
@@ -1288,9 +1296,13 @@
if (rettv_list_alloc(rettv) == OK)
{
# ifdef FEAT_SEARCH_EXTRA
- int id = (int)tv_get_number(&argvars[0]);
+ int id;
matchitem_T *m;
+ if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
+ return;
+
+ id = (int)tv_get_number(&argvars[0]);
if (id >= 1 && id <= 3)
{
if ((m = (matchitem_T *)get_match(curwin, id)) != NULL)
@@ -1316,8 +1328,14 @@
f_matchdelete(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
# ifdef FEAT_SEARCH_EXTRA
- win_T *win = get_optional_window(argvars, 1);
+ win_T *win;
+ if (in_vim9script()
+ && (check_for_number_arg(argvars, 0) == FAIL
+ || check_for_opt_number_arg(argvars, 1) == FAIL))
+ return;
+
+ win = get_optional_window(argvars, 1);
if (win == NULL)
rettv->vval.v_number = -1;
else