summaryrefslogtreecommitdiffstats
path: root/src/evalfunc.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-08-01 15:40:31 +0200
committerBram Moolenaar <Bram@vim.org>2021-08-01 15:40:31 +0200
commitf78da4f9d6daf1907e4ce4be74146375dbd9a546 (patch)
treec0ae83ae9823ae2d5f61a0580664ee0fd666b17d /src/evalfunc.c
parent73b8b0ae3acac220e823076f8ca1c14524ed96dd (diff)
patch 8.2.3269: Vim9: wrong argument check for partialv8.2.3269
Problem: Vim9: wrong argument check for partial. (Naohiro Ono) Solution: Handle getting return type without arguments. Correct the minimal number of arguments for what is included in the partial. (closes #8667)
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r--src/evalfunc.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 23a39aa4f2..ff0d33a4c3 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -932,22 +932,27 @@ ret_first_arg(int argcount, type_T **argtypes)
return &t_void;
}
static type_T *
-ret_repeat(int argcount UNUSED, type_T **argtypes)
+ret_repeat(int argcount, type_T **argtypes)
{
+ if (argcount == 0)
+ return &t_any;
if (argtypes[0] == &t_number)
return &t_string;
return argtypes[0];
}
// for map(): returns first argument but item type may differ
static type_T *
-ret_first_cont(int argcount UNUSED, type_T **argtypes)
+ret_first_cont(int argcount, type_T **argtypes)
{
- if (argtypes[0]->tt_type == VAR_LIST)
- return &t_list_any;
- if (argtypes[0]->tt_type == VAR_DICT)
- return &t_dict_any;
- if (argtypes[0]->tt_type == VAR_BLOB)
- return argtypes[0];
+ if (argcount > 0)
+ {
+ if (argtypes[0]->tt_type == VAR_LIST)
+ return &t_list_any;
+ if (argtypes[0]->tt_type == VAR_DICT)
+ return &t_dict_any;
+ if (argtypes[0]->tt_type == VAR_BLOB)
+ return argtypes[0];
+ }
return &t_any;
}
@@ -987,9 +992,9 @@ ret_argv(int argcount, type_T **argtypes UNUSED)
}
static type_T *
-ret_remove(int argcount UNUSED, type_T **argtypes)
+ret_remove(int argcount, type_T **argtypes)
{
- if (argtypes != NULL)
+ if (argcount > 0)
{
if (argtypes[0]->tt_type == VAR_LIST
|| argtypes[0]->tt_type == VAR_DICT)
@@ -2446,6 +2451,7 @@ internal_func_get_argcount(int idx, int *argcount, int *min_argcount)
* Call the "f_retfunc" function to obtain the return type of function "idx".
* "argtypes" is the list of argument types or NULL when there are no
* arguments.
+ * "argcount" may be less than the actual count when only getting the type.
*/
type_T *
internal_func_ret_type(int idx, int argcount, type_T **argtypes)