summaryrefslogtreecommitdiff
path: root/src/vim9compile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r--src/vim9compile.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c
index b4209a1fe..e5a801a28 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -4568,9 +4568,19 @@ compile_return(char_u *arg, int set_return_type, cctx_T *cctx)
stack_type = ((type_T **)stack->ga_data)[stack->ga_len - 1];
if (set_return_type)
cctx->ctx_ufunc->uf_ret_type = stack_type;
- else if (need_type(stack_type, cctx->ctx_ufunc->uf_ret_type, -1, cctx)
+ 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(_("E1096: Returning a value in a function without a return type"));
+ return NULL;
+ }
+ if (need_type(stack_type, cctx->ctx_ufunc->uf_ret_type, -1, cctx)
== FAIL)
return NULL;
+ }
}
else
{