1
0
forked from aniani/vim

patch 8.2.3188: Vim9: argument types are not checked at compile time

Problem:    Vim9: argument types are not checked at compile time.
Solution:   Add several more type checks, also at runtime. (Yegappan
            Lakshmanan, closes #8587)
This commit is contained in:
Yegappan Lakshmanan
2021-07-20 17:51:51 +02:00
committed by Bram Moolenaar
parent 9bb0dad0d8
commit 83494b4ac6
34 changed files with 1417 additions and 299 deletions

View File

@@ -1254,6 +1254,15 @@ f_glob(typval_T *argvars, typval_T *rettv)
expand_T xpc;
int error = FALSE;
if (in_vim9script()
&& (check_for_string_arg(argvars, 0) == FAIL
|| check_for_opt_bool_arg(argvars, 1) == FAIL
|| (argvars[1].v_type != VAR_UNKNOWN
&& (check_for_opt_bool_arg(argvars, 2) == FAIL
|| (argvars[2].v_type != VAR_UNKNOWN
&& check_for_opt_bool_arg(argvars, 3) == FAIL)))))
return;
// When the optional second argument is non-zero, don't remove matches
// for 'wildignore' and don't put matches for 'suffixes' at the end.
rettv->v_type = VAR_STRING;
@@ -1318,11 +1327,23 @@ f_globpath(typval_T *argvars, typval_T *rettv)
{
int flags = WILD_IGNORE_COMPLETESLASH;
char_u buf1[NUMBUFLEN];
char_u *file = tv_get_string_buf_chk(&argvars[1], buf1);
char_u *file;
int error = FALSE;
garray_T ga;
int i;
if (in_vim9script()
&& (check_for_string_arg(argvars, 0) == FAIL
|| check_for_string_arg(argvars, 1) == FAIL
|| check_for_opt_bool_arg(argvars, 2) == FAIL
|| (argvars[2].v_type != VAR_UNKNOWN
&& (check_for_opt_bool_arg(argvars, 3) == FAIL
|| (argvars[3].v_type != VAR_UNKNOWN
&& check_for_opt_bool_arg(argvars, 4) == FAIL)))))
return;
file = tv_get_string_buf_chk(&argvars[1], buf1);
// When the optional second argument is non-zero, don't remove matches
// for 'wildignore' and don't put matches for 'suffixes' at the end.
rettv->v_type = VAR_STRING;
@@ -1449,8 +1470,7 @@ f_pathshorten(typval_T *argvars, typval_T *rettv)
if (in_vim9script()
&& (check_for_string_arg(argvars, 0) == FAIL
|| (argvars[1].v_type != VAR_UNKNOWN
&& check_for_number_arg(argvars, 1) == FAIL)))
|| check_for_opt_number_arg(argvars, 1) == FAIL))
return;
if (argvars[1].v_type != VAR_UNKNOWN)
@@ -2423,10 +2443,12 @@ f_browse(typval_T *argvars UNUSED, typval_T *rettv)
int error = FALSE;
if (in_vim9script()
&& (check_for_string_arg(argvars, 1) == FAIL
&& (check_for_bool_arg(argvars, 0) == FAIL
|| check_for_string_arg(argvars, 1) == FAIL
|| check_for_string_arg(argvars, 2) == FAIL
|| check_for_string_arg(argvars, 3) == FAIL))
return;
save = (int)tv_get_number_chk(&argvars[0], &error);
title = tv_get_string_chk(&argvars[1]);
initdir = tv_get_string_buf_chk(&argvars[2], buf);