Mercurial > vim
diff src/match.c @ 25338:e2be9f3c5907 v8.2.3206
patch 8.2.3206: Vim9: argument types are not checked at compile time
Commit: https://github.com/vim/vim/commit/0ad871dc4dfe1026e14931a55c225616b63f4c5b
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Fri Jul 23 20:37:56 2021 +0200
patch 8.2.3206: 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. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/8611)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 23 Jul 2021 20:45:05 +0200 |
parents | 078edc1821bf |
children | e8e2c4d33b9b |
line wrap: on
line diff
--- a/src/match.c +++ b/src/match.c @@ -1163,8 +1163,8 @@ f_matchadd(typval_T *argvars UNUSED, typ { # ifdef FEAT_SEARCH_EXTRA char_u buf[NUMBUFLEN]; - char_u *grp = tv_get_string_buf_chk(&argvars[0], buf); // group - char_u *pat = tv_get_string_buf_chk(&argvars[1], buf); // pattern + char_u *grp; // group + char_u *pat; // pattern int prio = 10; // default priority int id = -1; int error = FALSE; @@ -1173,6 +1173,18 @@ f_matchadd(typval_T *argvars UNUSED, typ rettv->vval.v_number = -1; + if (in_vim9script() + && (check_for_string_arg(argvars, 0) == FAIL + || check_for_string_arg(argvars, 1) == FAIL + || check_for_opt_number_arg(argvars, 2) == FAIL + || (argvars[2].v_type != VAR_UNKNOWN + && (check_for_opt_number_arg(argvars, 3) == FAIL + || (argvars[3].v_type != VAR_UNKNOWN + && check_for_opt_dict_arg(argvars, 4) == FAIL))))) + return; + + grp = tv_get_string_buf_chk(&argvars[0], buf); // group + pat = tv_get_string_buf_chk(&argvars[1], buf); // pattern if (grp == NULL || pat == NULL) return; if (argvars[2].v_type != VAR_UNKNOWN) @@ -1217,6 +1229,16 @@ f_matchaddpos(typval_T *argvars UNUSED, rettv->vval.v_number = -1; + if (in_vim9script() + && (check_for_string_arg(argvars, 0) == FAIL + || check_for_list_arg(argvars, 1) == FAIL + || check_for_opt_number_arg(argvars, 2) == FAIL + || (argvars[2].v_type != VAR_UNKNOWN + && (check_for_opt_number_arg(argvars, 3) == FAIL + || (argvars[3].v_type != VAR_UNKNOWN + && check_for_opt_dict_arg(argvars, 4) == FAIL))))) + return; + group = tv_get_string_buf_chk(&argvars[0], buf); if (group == NULL) return;