0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.2.3221: 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 #8632)
This commit is contained in:
Yegappan Lakshmanan
2021-07-25 15:57:32 +02:00
committed by Bram Moolenaar
parent 2ec28aec9d
commit a764e73d4f
9 changed files with 189 additions and 17 deletions

View File

@@ -566,12 +566,23 @@ f_assert_exception(typval_T *argvars, typval_T *rettv)
void
f_assert_fails(typval_T *argvars, typval_T *rettv)
{
char_u *cmd = tv_get_string_chk(&argvars[0]);
char_u *cmd;
garray_T ga;
int save_trylevel = trylevel;
int called_emsg_before = called_emsg;
char *wrong_arg_msg = NULL;
if (check_for_string_or_number_arg(argvars, 0) == FAIL
|| check_for_opt_string_or_list_arg(argvars, 1) == FAIL
|| (argvars[1].v_type != VAR_UNKNOWN
&& (argvars[2].v_type != VAR_UNKNOWN
&& (check_for_opt_number_arg(argvars, 3) == FAIL
|| (argvars[3].v_type != VAR_UNKNOWN
&& check_for_opt_string_arg(argvars, 4) == FAIL)))))
return;
cmd = tv_get_string_chk(&argvars[0]);
// trylevel must be zero for a ":throw" command to be considered failed
trylevel = 0;
suppress_errthrow = TRUE;
@@ -799,6 +810,12 @@ assert_inrange(typval_T *argvars)
void
f_assert_inrange(typval_T *argvars, typval_T *rettv)
{
if (check_for_float_or_nr_arg(argvars, 0) == FAIL
|| check_for_float_or_nr_arg(argvars, 1) == FAIL
|| check_for_float_or_nr_arg(argvars, 2) == FAIL
|| check_for_opt_string_arg(argvars, 3) == FAIL)
return;
rettv->vval.v_number = assert_inrange(argvars);
}