To: vim_dev@googlegroups.com Subject: Patch 8.2.3448 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3448 Problem: :endtry after function call that throws not found. Solution: Do check for following :endtry if an exception is being thrown. (closes #8889) Files: src/userfunc.c, src/testdir/test_trycatch.vim *** ../vim-8.2.3447/src/userfunc.c 2021-09-08 15:33:25.160576403 +0200 --- src/userfunc.c 2021-09-18 13:53:22.659863603 +0200 *************** *** 5011,5024 **** --emsg_skip; clear_evalarg(&evalarg, eap); ! // When inside :try we need to check for following "| catch". ! if (!aborting() && (!failed || eap->cstack->cs_trylevel > 0)) { // Check for trailing illegal characters and a following command. arg = skipwhite(arg); if (!ends_excmd2(eap->arg, arg)) { ! if (!failed) { emsg_severe = TRUE; semsg(_(e_trailing_arg), arg); --- 5011,5026 ---- --emsg_skip; clear_evalarg(&evalarg, eap); ! // When inside :try we need to check for following "| catch" or "| endtry". ! // Not when there was an error, but do check if an exception was thrown. ! if ((!aborting() || did_throw) ! && (!failed || eap->cstack->cs_trylevel > 0)) { // Check for trailing illegal characters and a following command. arg = skipwhite(arg); if (!ends_excmd2(eap->arg, arg)) { ! if (!failed && !aborting()) { emsg_severe = TRUE; semsg(_(e_trailing_arg), arg); *** ../vim-8.2.3447/src/testdir/test_trycatch.vim 2021-09-08 15:33:25.160576403 +0200 --- src/testdir/test_trycatch.vim 2021-09-18 13:52:15.767808933 +0200 *************** *** 2236,2242 **** catch /my_error/ let caught = 'yes' catch ! let caught = 'no' endtry call assert_equal('yes', caught) END --- 2236,2242 ---- catch /my_error/ let caught = 'yes' catch ! let caught = v:exception endtry call assert_equal('yes', caught) END *************** *** 2247,2252 **** --- 2247,2278 ---- unlet g:caught endfunc + " Test for using throw in a called function with following endtry {{{1 + func Test_user_command_function_call_with_endtry() + let lines =<< trim END + funct s:throw(msg) abort + throw a:msg + endfunc + func s:main() abort + try + try + throw 'err1' + catch + call s:throw('err2') | endtry + catch + let s:caught = 'yes' + endtry + endfunc + + call s:main() + call assert_equal('yes', s:caught) + END + call writefile(lines, 'XtestThrow') + source XtestThrow + + call delete('XtestThrow') + endfunc + " Modeline {{{1 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker *** ../vim-8.2.3447/src/version.c 2021-09-18 12:15:03.691013353 +0200 --- src/version.c 2021-09-18 13:54:54.439917921 +0200 *************** *** 759,760 **** --- 759,762 ---- { /* Add new patch number below this line */ + /**/ + 3448, /**/ -- hundred-and-one symptoms of being an internet addict: 34. You laugh at people with a 10 Mbit connection. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///