summaryrefslogtreecommitdiffstats
path: root/src/typval.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-07-15 12:49:58 +0200
committerBram Moolenaar <Bram@vim.org>2021-07-15 12:49:58 +0200
commit1a71d31bf34b0b2b08517903826004ec6fd440e5 (patch)
tree05f54a00199737fe81fdf49e9ea72c09dba483d9 /src/typval.c
parentc816a2c22667108fcd61f445de2c926f78ff9fa7 (diff)
patch 8.2.3162: Vim9: argument types are not checked at compile timev8.2.3162
Problem: Vim9: argument types are not checked at compile time. Solution: Add more type checks. (Yegappan Lakshmanan, closes #8560)
Diffstat (limited to 'src/typval.c')
-rw-r--r--src/typval.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/typval.c b/src/typval.c
index b223318311..6e0b528e79 100644
--- a/src/typval.c
+++ b/src/typval.c
@@ -385,6 +385,23 @@ check_for_nonempty_string_arg(typval_T *args, int idx)
}
/*
+ * 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