summaryrefslogtreecommitdiff
path: root/src/textprop.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-07-27 22:00:44 +0200
committerBram Moolenaar <Bram@vim.org>2021-07-27 22:00:44 +0200
commit4490ec4e839e45a2e6923c265c7e9e64c240b805 (patch)
tree3ef2dc127890ac6a644f38ae7932b7e70071544a /src/textprop.c
parent5d7c2df536c17db4a9c61e0760bdcf78d0db7330 (diff)
downloadvim-git-4490ec4e839e45a2e6923c265c7e9e64c240b805.tar.gz
patch 8.2.3229: Vim9: runtime and compile time type checks are not the samev8.2.3229
Problem: Vim9: runtime and compile time type checks are not the same. Solution: Add more runtime type checks for builtin functions. (Yegappan Lakshmanan, closes #8646)
Diffstat (limited to 'src/textprop.c')
-rw-r--r--src/textprop.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/textprop.c b/src/textprop.c
index fdbb14df8..4cde75544 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -618,6 +618,11 @@ f_prop_find(typval_T *argvars, typval_T *rettv)
int dir = 1; // 1 = forward, -1 = backward
int both;
+ if (in_vim9script()
+ && (check_for_dict_arg(argvars, 0) == FAIL
+ || check_for_opt_string_arg(argvars, 1) == FAIL))
+ return;
+
if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL)
{
emsg(_(e_dictreq));
@@ -985,6 +990,11 @@ prop_type_set(typval_T *argvars, int add)
dictitem_T *di;
proptype_T *prop;
+ if (in_vim9script()
+ && (check_for_string_arg(argvars, 0) == FAIL
+ || check_for_dict_arg(argvars, 1) == FAIL))
+ return;
+
name = tv_get_string(&argvars[0]);
if (*name == NUL)
{
@@ -1115,6 +1125,11 @@ f_prop_type_delete(typval_T *argvars, typval_T *rettv UNUSED)
buf_T *buf = NULL;
hashitem_T *hi;
+ if (in_vim9script()
+ && (check_for_string_arg(argvars, 0) == FAIL
+ || check_for_opt_dict_arg(argvars, 1) == FAIL))
+ return;
+
name = tv_get_string(&argvars[0]);
if (*name == NUL)
{
@@ -1149,8 +1164,14 @@ f_prop_type_delete(typval_T *argvars, typval_T *rettv UNUSED)
void
f_prop_type_get(typval_T *argvars, typval_T *rettv)
{
- char_u *name = tv_get_string(&argvars[0]);
+ char_u *name;
+ if (in_vim9script()
+ && (check_for_string_arg(argvars, 0) == FAIL
+ || check_for_opt_dict_arg(argvars, 1) == FAIL))
+ return;
+
+ name = tv_get_string(&argvars[0]);
if (*name == NUL)
{
emsg(_(e_invarg));
@@ -1216,6 +1237,9 @@ f_prop_type_list(typval_T *argvars, typval_T *rettv UNUSED)
if (rettv_list_alloc(rettv) == OK)
{
+ if (in_vim9script() && check_for_opt_dict_arg(argvars, 0) == FAIL)
+ return;
+
if (argvars[0].v_type != VAR_UNKNOWN)
{
if (get_bufnr_from_arg(&argvars[0], &buf) == FAIL)