mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 14:38:32 +00:00
vim-patch:8.2.3221: Vim9: argument types are not checked at compile time (#23480)
Problem: Vim9: argument types are not checked at compile time.
Solution: Add several more type checks. (Yegappan Lakshmanan, closes vim/vim#8632)
a764e73d4f
Cherry-pick test_assert.vim change from patch 8.2.3229.
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
@@ -500,12 +500,23 @@ void f_assert_exception(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
/// "assert_fails(cmd [, error [, msg]])" function
|
||||
void f_assert_fails(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
const char *const cmd = tv_get_string_chk(&argvars[0]);
|
||||
garray_T ga;
|
||||
int save_trylevel = trylevel;
|
||||
const int save_trylevel = trylevel;
|
||||
const int called_emsg_before = called_emsg;
|
||||
const char *wrong_arg_msg = NULL;
|
||||
|
||||
if (tv_check_for_string_or_number_arg(argvars, 0) == FAIL
|
||||
|| tv_check_for_opt_string_or_list_arg(argvars, 1) == FAIL
|
||||
|| (argvars[1].v_type != VAR_UNKNOWN
|
||||
&& (argvars[2].v_type != VAR_UNKNOWN
|
||||
&& (tv_check_for_opt_number_arg(argvars, 3) == FAIL
|
||||
|| (argvars[3].v_type != VAR_UNKNOWN
|
||||
&& tv_check_for_opt_string_arg(argvars, 4) == FAIL))))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const char *const cmd = tv_get_string_chk(&argvars[0]);
|
||||
|
||||
// trylevel must be zero for a ":throw" command to be considered failed
|
||||
trylevel = 0;
|
||||
suppress_errthrow = true;
|
||||
@@ -682,6 +693,13 @@ static int assert_inrange(typval_T *argvars)
|
||||
/// "assert_inrange(lower, upper[, msg])" function
|
||||
void f_assert_inrange(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
if (tv_check_for_float_or_nr_arg(argvars, 0) == FAIL
|
||||
|| tv_check_for_float_or_nr_arg(argvars, 1) == FAIL
|
||||
|| tv_check_for_float_or_nr_arg(argvars, 2) == FAIL
|
||||
|| tv_check_for_opt_string_arg(argvars, 3) == FAIL) {
|
||||
return;
|
||||
}
|
||||
|
||||
rettv->vval.v_number = assert_inrange(argvars);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user