patch 8.2.2172: Vim9: number of arguments is not always checked
Problem: Vim9: number of arguments is not always checked. (Yegappan
Lakshmanan)
Solution: Check number of arguments when calling function by name.
diff --git a/src/vim9execute.c b/src/vim9execute.c
index 6409d88..606ce0c 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -606,6 +606,17 @@
return FAIL;
if (ufunc->uf_def_status == UF_COMPILED)
{
+ int error = check_user_func_argcount(ufunc, argcount);
+
+ if (error != FCERR_UNKNOWN)
+ {
+ if (error == FCERR_TOOMANY)
+ semsg(_(e_toomanyarg), ufunc->uf_name);
+ else
+ semsg(_(e_toofewarg), ufunc->uf_name);
+ return FAIL;
+ }
+
// The function has been compiled, can call it quickly. For a function
// that was defined later: we can call it directly next time.
if (iptr != NULL)