diff options
-rw-r--r-- | src/testdir/test_vim9_func.vim | 11 | ||||
-rw-r--r-- | src/userfunc.c | 6 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 19 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index e87c33e909..049532c69f 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -197,6 +197,17 @@ def Test_return_nothing() s:nothing->assert_equal(1) enddef +def Test_return_invalid() + var lines =<< trim END + vim9script + def Func(): invalid + return xxx + enddef + defcompile + END + CheckScriptFailure(lines, 'E1010:', 2) +enddef + func Increment() let g:counter += 1 endfunc diff --git a/src/userfunc.c b/src/userfunc.c index ded9ef7b0f..7ca8186e13 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -3886,6 +3886,12 @@ define_function(exarg_T *eap, char_u *name_arg) { p = ret_type; fp->uf_ret_type = parse_type(&p, &fp->uf_type_list, TRUE); + if (fp->uf_ret_type == NULL) + { + fp->uf_ret_type = &t_void; + SOURCING_LNUM = lnum_save; + goto erret; + } } SOURCING_LNUM = lnum_save; } diff --git a/src/version.c b/src/version.c index 9d217e2a06..e7417402fb 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2357, +/**/ 2356, /**/ 2355, |