diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2021-07-25 15:57:32 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-07-25 15:57:32 +0200 |
commit | a764e73d4ffc5d046807c757eaacb9b0a5408152 (patch) | |
tree | 477a5065575e437a5496ead0e45ac8ff5ee5671c /src/testing.c | |
parent | 2ec28aec9d4f1b9c1c008e36adde9fc82affae0f (diff) | |
download | vim-git-a764e73d4ffc5d046807c757eaacb9b0a5408152.tar.gz |
patch 8.2.3221: Vim9: argument types are not checked at compile timev8.2.3221
Problem: Vim9: argument types are not checked at compile time.
Solution: Add several more type checks. (Yegappan Lakshmanan, closes #8632)
Diffstat (limited to 'src/testing.c')
-rw-r--r-- | src/testing.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/testing.c b/src/testing.c index 9f3c29422..1da1c1cab 100644 --- a/src/testing.c +++ b/src/testing.c @@ -566,12 +566,23 @@ f_assert_exception(typval_T *argvars, typval_T *rettv) void f_assert_fails(typval_T *argvars, typval_T *rettv) { - char_u *cmd = tv_get_string_chk(&argvars[0]); + char_u *cmd; garray_T ga; int save_trylevel = trylevel; int called_emsg_before = called_emsg; char *wrong_arg_msg = NULL; + if (check_for_string_or_number_arg(argvars, 0) == FAIL + || check_for_opt_string_or_list_arg(argvars, 1) == FAIL + || (argvars[1].v_type != VAR_UNKNOWN + && (argvars[2].v_type != VAR_UNKNOWN + && (check_for_opt_number_arg(argvars, 3) == FAIL + || (argvars[3].v_type != VAR_UNKNOWN + && check_for_opt_string_arg(argvars, 4) == FAIL))))) + return; + + cmd = tv_get_string_chk(&argvars[0]); + // trylevel must be zero for a ":throw" command to be considered failed trylevel = 0; suppress_errthrow = TRUE; @@ -799,6 +810,12 @@ assert_inrange(typval_T *argvars) void f_assert_inrange(typval_T *argvars, typval_T *rettv) { + if (check_for_float_or_nr_arg(argvars, 0) == FAIL + || check_for_float_or_nr_arg(argvars, 1) == FAIL + || check_for_float_or_nr_arg(argvars, 2) == FAIL + || check_for_opt_string_arg(argvars, 3) == FAIL) + return; + rettv->vval.v_number = assert_inrange(argvars); } |