patch 8.2.3269: Vim9: wrong argument check for partial
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)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 23a39aa..ff0d33a 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -932,22 +932,27 @@
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 @@
}
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 @@
* 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)