0
0
mirror of https://github.com/vim/vim.git synced 2025-10-28 09:27:14 -04:00

patch 8.2.3206: Vim9: argument types are not checked at compile time

Problem:    Vim9: argument types are not checked at compile time.
Solution:   Add several more type checks. (Yegappan Lakshmanan, closes #8611)
This commit is contained in:
Yegappan Lakshmanan
2021-07-23 20:37:56 +02:00
committed by Bram Moolenaar
parent 1b862c466b
commit 0ad871dc4d
19 changed files with 461 additions and 157 deletions

View File

@@ -1163,8 +1163,8 @@ f_matchadd(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
# ifdef FEAT_SEARCH_EXTRA
char_u buf[NUMBUFLEN];
char_u *grp = tv_get_string_buf_chk(&argvars[0], buf); // group
char_u *pat = tv_get_string_buf_chk(&argvars[1], buf); // pattern
char_u *grp; // group
char_u *pat; // pattern
int prio = 10; // default priority
int id = -1;
int error = FALSE;
@@ -1173,6 +1173,18 @@ f_matchadd(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
rettv->vval.v_number = -1;
if (in_vim9script()
&& (check_for_string_arg(argvars, 0) == FAIL
|| check_for_string_arg(argvars, 1) == FAIL
|| check_for_opt_number_arg(argvars, 2) == FAIL
|| (argvars[2].v_type != VAR_UNKNOWN
&& (check_for_opt_number_arg(argvars, 3) == FAIL
|| (argvars[3].v_type != VAR_UNKNOWN
&& check_for_opt_dict_arg(argvars, 4) == FAIL)))))
return;
grp = tv_get_string_buf_chk(&argvars[0], buf); // group
pat = tv_get_string_buf_chk(&argvars[1], buf); // pattern
if (grp == NULL || pat == NULL)
return;
if (argvars[2].v_type != VAR_UNKNOWN)
@@ -1217,6 +1229,16 @@ f_matchaddpos(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
rettv->vval.v_number = -1;
if (in_vim9script()
&& (check_for_string_arg(argvars, 0) == FAIL
|| check_for_list_arg(argvars, 1) == FAIL
|| check_for_opt_number_arg(argvars, 2) == FAIL
|| (argvars[2].v_type != VAR_UNKNOWN
&& (check_for_opt_number_arg(argvars, 3) == FAIL
|| (argvars[3].v_type != VAR_UNKNOWN
&& check_for_opt_dict_arg(argvars, 4) == FAIL)))))
return;
group = tv_get_string_buf_chk(&argvars[0], buf);
if (group == NULL)
return;