ReturnString()->assert_equal('string')
ReturnNumber()->assert_equal(123)
assert_fails('ReturnGlobal()', 'E1012: Type mismatch; expected number but got string', '', 1, 'ReturnGlobal')
+
+ var lines =<< trim END
+ vim9script
+
+ def Msg()
+ echomsg 'in Msg()...'
+ enddef
+
+ def Func()
+ return Msg()
+ enddef
+ defcompile
+ END
+ CheckScriptFailure(lines, 'E1096:')
enddef
def Test_check_argument_type()
if (*p != NUL && *p != '|' && *p != '\n')
{
+ if (cctx->ctx_ufunc->uf_ret_type->tt_type == VAR_VOID)
+ {
+ emsg(_(e_returning_value_in_function_without_return_type));
+ return NULL;
+ }
if (legacy)
{
int save_flags = cmdmod.cmod_flags;
}
else
{
- if (cctx->ctx_ufunc->uf_ret_type->tt_type == VAR_VOID
- && stack_type->tt_type != VAR_VOID
- && stack_type->tt_type != VAR_UNKNOWN)
- {
- emsg(_(e_returning_value_in_function_without_return_type));
- return NULL;
- }
if (need_type(stack_type, cctx->ctx_ufunc->uf_ret_type, -1,
0, cctx, FALSE, FALSE) == FAIL)
return NULL;