assert_equal('one,two,three', MyVarargs('one', 'two', 'three'))
enddef
+"def Test_call_func_defined_later()
+" call assert_equal('one', DefineLater('one'))
+" call assert_fails('call NotDefined("one")', 'E99:')
+"enddef
+
+func DefineLater(arg)
+ return a:arg
+endfunc
+
+def MyDefaultArgs(name = 'string'): string
+ return name
+enddef
+
+func Test_call_default_args_from_func()
+ " TODO: implement using default value for optional argument
+ "call assert_equal('string', MyDefaultArgs())
+ call assert_fails('call MyDefaultArgs()', 'optional arguments not implemented yet')
+ call assert_equal('one', MyDefaultArgs('one'))
+ call assert_fails('call MyDefaultArgs("one", "two")', 'E118:')
+endfunc
+
+def Test_call_default_args()
+ " TODO: implement using default value for optional argument
+ "assert_equal('string', MyDefaultArgs())
+ assert_equal('one', MyDefaultArgs('one'))
+ assert_fails('call MyDefaultArgs("one", "two")', 'E118:')
+enddef
+
def Test_return_type_wrong()
" TODO: why is ! needed for Mac and FreeBSD?
CheckScriptFailure(['def Func(): number', 'return "a"', 'enddef'], 'expected number but got string')
isn->isn_arg.ufunc.cuf_argcount = argcount;
stack->ga_len -= argcount; // drop the arguments
-
- // drop the funcref/partial, get back the return value
- ((type_T **)stack->ga_data)[stack->ga_len - 1] = &t_any;
+ if (ga_grow(stack, 1) == FAIL)
+ return FAIL;
+ // add return value
+ ((type_T **)stack->ga_data)[stack->ga_len] = &t_any;
+ ++stack->ga_len;
return OK;
}
int idx;
int ret = FAIL;
dfunc_T *dfunc;
+ int optcount = ufunc_argcount(ufunc) - argc;
// Get pointer to item in the stack.
#define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx)
ectx.ec_frame = ectx.ec_stack.ga_len;
initial_frame_ptr = ectx.ec_frame;
+// TODO: Put omitted argument default values on the stack.
+ if (optcount > 0)
+ {
+ emsg("optional arguments not implemented yet");
+ return FAIL;
+ }
// dummy frame entries
for (idx = 0; idx < STACK_FRAME_SIZE; ++idx)
{