To: vim_dev@googlegroups.com Subject: Patch 8.2.2351 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2351 Problem: Vim9: error message for "throw" in function that was called with "silent!". Solution: Do not throw the exception when not caught or displayed. (closes #7672) Files: src/vim9execute.c, src/testdir/test_vim9_script.vim *** ../vim-8.2.2350/src/vim9execute.c 2021-01-13 21:46:53.832589880 +0100 --- src/vim9execute.c 2021-01-14 21:39:17.068731918 +0100 *************** *** 2605,2610 **** --- 2605,2621 ---- break; case ISN_THROW: + if (ectx.ec_trystack.ga_len == 0 && trylevel == 0 + && emsg_silent) + { + // throwing an exception while using "silent!" causes the + // function to abort but not display an error. + tv = STACK_TV_BOT(-1); + clear_tv(tv); + tv->v_type = VAR_NUMBER; + tv->vval.v_number = 0; + goto done; + } --ectx.ec_stack.ga_len; tv = STACK_TV_BOT(0); if (tv->vval.v_string == NULL *** ../vim-8.2.2350/src/testdir/test_vim9_script.vim 2021-01-11 20:17:30.395385392 +0100 --- src/testdir/test_vim9_script.vim 2021-01-14 21:38:07.196903712 +0100 *************** *** 564,569 **** --- 564,582 ---- endif enddef + def Test_nocatch_throw_silenced() + var lines =<< trim END + vim9script + def Func() + throw 'error' + enddef + silent! Func() + END + writefile(lines, 'XthrowSilenced') + source XthrowSilenced + delete('XthrowSilenced') + enddef + def DeletedFunc(): list return ['delete me'] enddef *** ../vim-8.2.2350/src/version.c 2021-01-14 21:40:13.456592104 +0100 --- src/version.c 2021-01-14 21:43:06.712157433 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2351, /**/ -- hundred-and-one symptoms of being an internet addict: 148. You find it easier to dial-up the National Weather Service Weather/your_town/now.html than to simply look out the window. /// 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 ///