From 1a71d31bf34b0b2b08517903826004ec6fd440e5 Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Thu, 15 Jul 2021 12:49:58 +0200 Subject: 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) --- src/typval.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/typval.c') diff --git a/src/typval.c b/src/typval.c index b22331831..6e0b528e7 100644 --- a/src/typval.c +++ b/src/typval.c @@ -384,6 +384,23 @@ check_for_nonempty_string_arg(typval_T *args, int idx) return OK; } +/* + * 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. */ -- cgit v1.2.1