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;
}
}
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)
* 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)
enddef
def Test_partial_call()
- var Xsetlist = function('setloclist', [0])
- Xsetlist([], ' ', {title: 'test'})
- getloclist(0, {title: 1})->assert_equal({title: 'test'})
+ var lines =<< trim END
+ var Xsetlist: func
+ Xsetlist = function('setloclist', [0])
+ Xsetlist([], ' ', {title: 'test'})
+ getloclist(0, {title: 1})->assert_equal({title: 'test'})
+
+ Xsetlist = function('setloclist', [0, [], ' '])
+ Xsetlist({title: 'test'})
+ getloclist(0, {title: 1})->assert_equal({title: 'test'})
- Xsetlist = function('setloclist', [0, [], ' '])
- Xsetlist({title: 'test'})
- getloclist(0, {title: 1})->assert_equal({title: 'test'})
+ Xsetlist = function('setqflist')
+ Xsetlist([], ' ', {title: 'test'})
+ getqflist({title: 1})->assert_equal({title: 'test'})
- Xsetlist = function('setqflist')
- Xsetlist([], ' ', {title: 'test'})
- getqflist({title: 1})->assert_equal({title: 'test'})
+ Xsetlist = function('setqflist', [[], ' '])
+ Xsetlist({title: 'test'})
+ getqflist({title: 1})->assert_equal({title: 'test'})
- Xsetlist = function('setqflist', [[], ' '])
- Xsetlist({title: 'test'})
- getqflist({title: 1})->assert_equal({title: 'test'})
+ var Len: func: number = function('len', ['word'])
+ assert_equal(4, Len())
- var Len: func: number = function('len', ['word'])
- assert_equal(4, Len())
+ var RepeatFunc = function('repeat', ['o'])
+ assert_equal('ooooo', RepeatFunc(5))
+ END
+ CheckDefAndScriptSuccess(lines)
enddef
def Test_cmd_modifier()
type->tt_type = tv->v_type;
type->tt_argcount = argcount;
type->tt_min_argcount = min_argcount;
+ if (tv->v_type == VAR_PARTIAL && tv->vval.v_partial->pt_argc > 0)
+ {
+ type->tt_argcount -= tv->vval.v_partial->pt_argc;
+ type->tt_min_argcount -= tv->vval.v_partial->pt_argc;
+ }
type->tt_member = member_type;
return type;