patch 8.2.3162: Vim9: argument types are not checked at compile time
Problem: Vim9: argument types are not checked at compile time.
Solution: Add more type checks. (Yegappan Lakshmanan, closes #8560)
diff --git a/src/testing.c b/src/testing.c
index 80596d4..42030d7 100644
--- a/src/testing.c
+++ b/src/testing.c
@@ -340,10 +340,14 @@
static int
assert_beeps(typval_T *argvars, int no_beep)
{
- char_u *cmd = tv_get_string_chk(&argvars[0]);
+ char_u *cmd;
garray_T ga;
int ret = 0;
+ if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
+ return 0;
+
+ cmd = tv_get_string_chk(&argvars[0]);
called_vim_beep = FALSE;
suppress_errthrow = TRUE;
emsg_silent = FALSE;
@@ -367,7 +371,7 @@
}
/*
- * "assert_beeps(cmd [, error])" function
+ * "assert_beeps(cmd)" function
*/
void
f_assert_beeps(typval_T *argvars, typval_T *rettv)
@@ -376,7 +380,7 @@
}
/*
- * "assert_nobeep(cmd [, error])" function
+ * "assert_nobeep(cmd)" function
*/
void
f_assert_nobeep(typval_T *argvars, typval_T *rettv)
@@ -947,6 +951,11 @@
int val;
static int save_starting = -1;
+ if (in_vim9script()
+ && (check_for_string_arg(argvars, 0) == FAIL
+ || check_for_number_arg(argvars, 1) == FAIL))
+ return;
+
if (argvars[0].v_type != VAR_STRING
|| (argvars[1].v_type) != VAR_NUMBER)
emsg(_(e_invarg));