Mercurial > vim
diff src/typval.c @ 26731:7f4cc4e58f75 v8.2.3894
patch 8.2.3894: Vim9: no proper type check for first argument of call()
Commit: https://github.com/vim/vim/commit/223d0a6bc8dc68039ceb6660de9576fafe178d73
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 25 19:29:21 2021 +0000
patch 8.2.3894: Vim9: no proper type check for first argument of call()
Problem: Vim9: no proper type check for first argument of call().
Solution: Add specific type check.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 25 Dec 2021 20:30:03 +0100 |
parents | 1cee572f2fd7 |
children | b7b82279426f |
line wrap: on
line diff
--- a/src/typval.c +++ b/src/typval.c @@ -757,6 +757,23 @@ check_for_string_or_list_or_dict_arg(typ } /* + * Give an error and return FAIL unless "args[idx]" is a string + * or a function reference. + */ + int +check_for_string_or_func_arg(typval_T *args, int idx) +{ + if (args[idx].v_type != VAR_PARTIAL + && args[idx].v_type != VAR_FUNC + && args[idx].v_type != VAR_STRING) + { + semsg(_(e_string_or_function_required_for_argument_nr), idx + 1); + return FAIL; + } + return OK; +} + +/* * Give an error and return FAIL unless "args[idx]" is a list or a blob. */ int