# HG changeset patch # User Bram Moolenaar # Date 1610734503 -3600 # Node ID ca98d85e92da7408c7f677b0a60bff475a3cbdd0 # Parent b4d2d03559b26c0e9e250999a837e271d32298d2 patch 8.2.2357: Vim9: crash when parsing function return type fails Commit: https://github.com/vim/vim/commit/648ea76e1d8ca9a9788f88d0d96d0cf0653006bb Author: Bram Moolenaar Date: Fri Jan 15 19:04:32 2021 +0100 patch 8.2.2357: Vim9: crash when parsing function return type fails Problem: Vim9: crash when parsing function return type fails. Solution: Bail out and set return type to "unknown". (closes https://github.com/vim/vim/issues/7685) diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim --- 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 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -3886,6 +3886,12 @@ define_function(exarg_T *eap, char_u *na { 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 --- 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,