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/typval.c b/src/typval.c
index b223318..6e0b528 100644
--- a/src/typval.c
+++ b/src/typval.c
@@ -385,6 +385,23 @@
}
/*
+ * Give an error and return FAIL unless "tv" is a number.
+ */
+ int
+check_for_number_arg(typval_T *args, int idx)
+{
+ if (args[idx].v_type != VAR_NUMBER)
+ {
+ if (idx >= 0)
+ semsg(_(e_number_required_for_argument_nr), idx + 1);
+ else
+ emsg(_(e_numberreq));
+ return FAIL;
+ }
+ return OK;
+}
+
+/*
* Give an error and return FAIL unless "tv" is a dict.
*/
int