1
0
forked from aniani/vim

patch 8.2.3904: Vim9: skip expression type is not checked at compile time

Problem:    Vim9: skip expression type is not checked at compile time.
Solution:   Add argument type checks.
This commit is contained in:
Bram Moolenaar
2021-12-26 17:18:14 +00:00
parent 71c41255f6
commit 7319981f21
3 changed files with 65 additions and 9 deletions

View File

@@ -532,6 +532,26 @@ arg_map_func(type_T *type, argcontext_T *context)
return OK;
}
/*
* Check an expression argument, can be a string, funcref or partial.
* Also accept a bool, a constant resulting from compiling a string argument.
* Also accept a number, one and zero are accepted.
*/
static int
arg_string_or_func(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
|| type->tt_type == VAR_UNKNOWN
|| type->tt_type == VAR_STRING
|| type->tt_type == VAR_PARTIAL
|| type->tt_type == VAR_FUNC
|| type->tt_type == VAR_BOOL
|| type->tt_type == VAR_NUMBER)
return OK;
arg_type_mismatch(&t_func_any, type, context->arg_idx + 1);
return FAIL;
}
/*
* Check "type" is a list of 'any' or a blob or a string.
*/
@@ -916,8 +936,8 @@ static argcheck_T arg23_reduce[] = {arg_string_list_or_blob, NULL, NULL};
static argcheck_T arg24_remote_expr[] = {arg_string, arg_string, arg_string, arg_number};
static argcheck_T arg23_remove[] = {arg_list_or_dict_or_blob, arg_remove2, arg_number};
static argcheck_T arg2_repeat[] = {arg_repeat1, arg_number};
static argcheck_T arg15_search[] = {arg_string, arg_string, arg_number, arg_number, NULL};
static argcheck_T arg37_searchpair[] = {arg_string, arg_string, arg_string, arg_string, NULL, arg_number, arg_number};
static argcheck_T arg15_search[] = {arg_string, arg_string, arg_number, arg_number, arg_string_or_func};
static argcheck_T arg37_searchpair[] = {arg_string, arg_string, arg_string, arg_string, arg_string_or_func, arg_number, arg_number};
static argcheck_T arg3_setbufline[] = {arg_buffer, arg_lnum, arg_str_or_nr_or_list};
static argcheck_T arg2_setline[] = {arg_lnum, NULL};
static argcheck_T arg24_setloclist[] = {arg_number, arg_list_any, arg_string, arg_dict_any};