diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-01-15 19:04:32 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-01-15 19:04:32 +0100 |
commit | 648ea76e1d8ca9a9788f88d0d96d0cf0653006bb (patch) | |
tree | ecf8cdbfce3d100d8754489dd703a617f2829093 | |
parent | 883cf97f109d2ff281cf77f7b2e3bb44aced7cb3 (diff) |
patch 8.2.2357: Vim9: crash when parsing function return type failsv8.2.2357
Problem: Vim9: crash when parsing function return type fails.
Solution: Bail out and set return type to "unknown". (closes #7685)
-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, |