comparison 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
comparison
equal deleted inserted replaced
25251:6024f64e0d2b 25252:acda780ffc3e
338 } 338 }
339 339
340 static int 340 static int
341 assert_beeps(typval_T *argvars, int no_beep) 341 assert_beeps(typval_T *argvars, int no_beep)
342 { 342 {
343 char_u *cmd = tv_get_string_chk(&argvars[0]); 343 char_u *cmd;
344 garray_T ga; 344 garray_T ga;
345 int ret = 0; 345 int ret = 0;
346 346
347 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
348 return 0;
349
350 cmd = tv_get_string_chk(&argvars[0]);
347 called_vim_beep = FALSE; 351 called_vim_beep = FALSE;
348 suppress_errthrow = TRUE; 352 suppress_errthrow = TRUE;
349 emsg_silent = FALSE; 353 emsg_silent = FALSE;
350 do_cmdline_cmd(cmd); 354 do_cmdline_cmd(cmd);
351 if (no_beep ? called_vim_beep : !called_vim_beep) 355 if (no_beep ? called_vim_beep : !called_vim_beep)
365 emsg_on_display = FALSE; 369 emsg_on_display = FALSE;
366 return ret; 370 return ret;
367 } 371 }
368 372
369 /* 373 /*
370 * "assert_beeps(cmd [, error])" function 374 * "assert_beeps(cmd)" function
371 */ 375 */
372 void 376 void
373 f_assert_beeps(typval_T *argvars, typval_T *rettv) 377 f_assert_beeps(typval_T *argvars, typval_T *rettv)
374 { 378 {
375 rettv->vval.v_number = assert_beeps(argvars, FALSE); 379 rettv->vval.v_number = assert_beeps(argvars, FALSE);
376 } 380 }
377 381
378 /* 382 /*
379 * "assert_nobeep(cmd [, error])" function 383 * "assert_nobeep(cmd)" function
380 */ 384 */
381 void 385 void
382 f_assert_nobeep(typval_T *argvars, typval_T *rettv) 386 f_assert_nobeep(typval_T *argvars, typval_T *rettv)
383 { 387 {
384 rettv->vval.v_number = assert_beeps(argvars, TRUE); 388 rettv->vval.v_number = assert_beeps(argvars, TRUE);
945 { 949 {
946 char_u *name = (char_u *)""; 950 char_u *name = (char_u *)"";
947 int val; 951 int val;
948 static int save_starting = -1; 952 static int save_starting = -1;
949 953
954 if (in_vim9script()
955 && (check_for_string_arg(argvars, 0) == FAIL
956 || check_for_number_arg(argvars, 1) == FAIL))
957 return;
958
950 if (argvars[0].v_type != VAR_STRING 959 if (argvars[0].v_type != VAR_STRING
951 || (argvars[1].v_type) != VAR_NUMBER) 960 || (argvars[1].v_type) != VAR_NUMBER)
952 emsg(_(e_invarg)); 961 emsg(_(e_invarg));
953 else 962 else
954 { 963 {