diff src/testing.c @ 25252:acda780ffc3e v8.2.3162

patch 8.2.3162: Vim9: argument types are not checked at compile time Commit: https://github.com/vim/vim/commit/1a71d31bf34b0b2b08517903826004ec6fd440e5 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Thu Jul 15 12:49:58 2021 +0200 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 https://github.com/vim/vim/issues/8560)
author Bram Moolenaar <Bram@vim.org>
date Thu, 15 Jul 2021 13:00:06 +0200
parents a703b3f28ef4
children 4d3c68196d05
line wrap: on
line diff
--- a/src/testing.c
+++ b/src/testing.c
@@ -340,10 +340,14 @@ assert_append_cmd_or_arg(garray_T *gap, 
     static int
 assert_beeps(typval_T *argvars, int no_beep)
 {
-    char_u	*cmd = tv_get_string_chk(&argvars[0]);
+    char_u	*cmd;
     garray_T	ga;
     int		ret = 0;
 
+    if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
+	return 0;
+
+    cmd = tv_get_string_chk(&argvars[0]);
     called_vim_beep = FALSE;
     suppress_errthrow = TRUE;
     emsg_silent = FALSE;
@@ -367,7 +371,7 @@ assert_beeps(typval_T *argvars, int no_b
 }
 
 /*
- * "assert_beeps(cmd [, error])" function
+ * "assert_beeps(cmd)" function
  */
     void
 f_assert_beeps(typval_T *argvars, typval_T *rettv)
@@ -376,7 +380,7 @@ f_assert_beeps(typval_T *argvars, typval
 }
 
 /*
- * "assert_nobeep(cmd [, error])" function
+ * "assert_nobeep(cmd)" function
  */
     void
 f_assert_nobeep(typval_T *argvars, typval_T *rettv)
@@ -947,6 +951,11 @@ f_test_override(typval_T *argvars, typva
     int     val;
     static int save_starting = -1;
 
+    if (in_vim9script()
+	    && (check_for_string_arg(argvars, 0) == FAIL
+		|| check_for_number_arg(argvars, 1) == FAIL))
+	return;
+
     if (argvars[0].v_type != VAR_STRING
 	    || (argvars[1].v_type) != VAR_NUMBER)
 	emsg(_(e_invarg));