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)
diff --git a/src/testing.c b/src/testing.c
index 9f3c294..1da1c1c 100644
--- a/src/testing.c
+++ b/src/testing.c
@@ -566,12 +566,23 @@
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 @@
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);
}