call CheckDefFailure(['TakesOneArg(11, 22)'], 'E118:')
call CheckDefFailure(['bufnr(xxx)'], 'E1001:')
call CheckScriptFailure(['def Func(Ref: func(s: string))'], 'E475:')
+
+ let lines =<< trim END
+ vim9script
+ def Func(s: string)
+ echo s
+ enddef
+ Func([])
+ END
+ call CheckScriptFailure(lines, 'E1012: type mismatch, expected string but got list<unknown>', 5)
enddef
" Default arg and varargs
if (fp->uf_def_status != UF_NOT_COMPILED)
{
- estack_push_ufunc(fp, 1);
- save_current_sctx = current_sctx;
- current_sctx = fp->uf_script_ctx;
-
// Execute the function, possibly compiling it first.
call_def_function(fp, argcount, argvars, funcexe->partial, rettv);
--depth;
current_funccal = fc->caller;
-
- estack_pop();
- current_sctx = save_current_sctx;
free_funccal(fc);
return;
}
int idx;
int ret = FAIL;
int defcount = ufunc->uf_args.ga_len - argc;
- int save_sc_version = current_sctx.sc_version;
+ sctx_T save_current_sctx = current_sctx;
int breakcheck_count = 0;
int called_emsg_before = called_emsg;
ectx.ec_instr = dfunc->df_instr;
}
+ // Following errors are in the function, not the caller.
// Commands behave like vim9script.
+ estack_push_ufunc(ufunc, 1);
+ current_sctx = ufunc->uf_script_ctx;
current_sctx.sc_version = SCRIPT_VERSION_VIM9;
// Decide where to start execution, handles optional arguments.
// When failed need to unwind the call stack.
while (ectx.ec_frame_idx != initial_frame_idx)
func_return(&ectx);
-failed_early:
- current_sctx.sc_version = save_sc_version;
+ estack_pop();
+ current_sctx = save_current_sctx;
+
+failed_early:
// Free all local variables, but not arguments.
for (idx = 0; idx < ectx.ec_stack.ga_len; ++idx)
clear_tv(STACK_TV(idx));