summaryrefslogtreecommitdiffstats
path: root/src/evalfunc.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-07-05 20:55:29 +0200
committerBram Moolenaar <Bram@vim.org>2020-07-05 20:55:29 +0200
commitad7c24932725b9ab37b65fe359a41f8ba3e3dfcf (patch)
tree4e35150a14c863e117d6997ba08ea4b6ae592e51 /src/evalfunc.c
parent252e88a78535d239ec4b764d8e3f04aad5a94a76 (diff)
patch 8.2.1143: Vim9: return type of remove() is anyv8.2.1143
Problem: Vim9: return type of remove() is any. Solution: Use the member type of the first argument, if known.
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r--src/evalfunc.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 65c34cd6a0..83b878b37c 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -382,6 +382,17 @@ ret_argv(int argcount, type_T **argtypes UNUSED)
return &t_any;
}
+ static type_T *
+ret_remove(int argcount UNUSED, type_T **argtypes)
+{
+ if (argtypes[0]->tt_type == VAR_LIST
+ || argtypes[0]->tt_type == VAR_DICT)
+ return argtypes[0]->tt_member;
+ if (argtypes[0]->tt_type == VAR_BLOB)
+ return &t_number;
+ return &t_any;
+}
+
static type_T *ret_f_function(int argcount, type_T **argtypes);
/*
@@ -827,7 +838,7 @@ static funcentry_T global_functions[] =
{"remote_read", 1, 2, FEARG_1, ret_string, f_remote_read},
{"remote_send", 2, 3, FEARG_1, ret_string, f_remote_send},
{"remote_startserver", 1, 1, FEARG_1, ret_void, f_remote_startserver},
- {"remove", 2, 3, FEARG_1, ret_any, f_remove},
+ {"remove", 2, 3, FEARG_1, ret_remove, f_remove},
{"rename", 2, 2, FEARG_1, ret_number, f_rename},
{"repeat", 2, 2, FEARG_1, ret_first_arg, f_repeat},
{"resolve", 1, 1, FEARG_1, ret_string, f_resolve},