To: vim_dev@googlegroups.com Subject: Patch 8.2.2357 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2357 Problem: Vim9: crash when parsing function return type fails. Solution: Bail out and set return type to "unknown". (closes #7685) Files: src/userfunc.c, src/testdir/test_vim9_func.vim *** ../vim-8.2.2356/src/userfunc.c 2021-01-08 22:24:16.467725889 +0100 --- src/userfunc.c 2021-01-15 18:55:17.947225612 +0100 *************** *** 3886,3891 **** --- 3886,3897 ---- { 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; } *** ../vim-8.2.2356/src/testdir/test_vim9_func.vim 2021-01-10 22:42:46.920847063 +0100 --- src/testdir/test_vim9_func.vim 2021-01-15 18:59:38.658602165 +0100 *************** *** 197,202 **** --- 197,213 ---- 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 *** ../vim-8.2.2356/src/version.c 2021-01-15 18:04:40.102419940 +0100 --- src/version.c 2021-01-15 19:04:14.233946909 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2357, /**/ -- hundred-and-one symptoms of being an internet addict: 156. You forget your friend's name but not her e-mail address. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///