patch 8.2.3173: 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 #8581)
diff --git a/src/strings.c b/src/strings.c
index a87922d..98d420c 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -902,6 +902,12 @@
if (rettv_list_alloc(rettv) == FAIL)
return;
+ if (in_vim9script()
+ && (check_for_string_arg(argvars, 0) == FAIL
+ || (argvars[1].v_type != VAR_UNKNOWN
+ && check_for_bool_arg(argvars, 1) == FAIL)))
+ return;
+
if (argvars[1].v_type != VAR_UNKNOWN)
utf8 = (int)tv_get_bool_chk(&argvars[1], NULL);
@@ -1108,6 +1114,12 @@
{
varnumber_T skipcc = FALSE;
+ if (in_vim9script()
+ && (check_for_string_arg(argvars, 0) == FAIL
+ || (argvars[1].v_type != VAR_UNKNOWN
+ && check_for_bool_arg(argvars, 1) == FAIL)))
+ return;
+
if (argvars[1].v_type != VAR_UNKNOWN)
skipcc = tv_get_bool(&argvars[1]);
if (skipcc < 0 || skipcc > 1)