]> granicus.if.org Git - vim/commitdiff
patch 8.2.3416: second error is reported while exception is being thrown v8.2.3416
authorBram Moolenaar <Bram@vim.org>
Wed, 8 Sep 2021 13:33:30 +0000 (15:33 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 8 Sep 2021 13:33:30 +0000 (15:33 +0200)
Problem:    Second error is reported while exception is being thrown.
Solution:   Do not check for trailing characters when already aborting.
            (closes #8842)

src/testdir/test_trycatch.vim
src/userfunc.c
src/version.c

index b5ad14c2a57dfe5ef8747a5ceb355bf518ca33b3..702d6dabb610d422b79f2231442c3ec552a9dbbb 100644 (file)
@@ -2224,5 +2224,29 @@ func Test_user_command_try_catch()
   unlet g:caught
 endfunc
 
+" Test for using throw in a called function with following error    {{{1
+func Test_user_command_throw_in_function_call()
+  let lines =<< trim END
+      function s:get_dict() abort
+        throw 'my_error'
+      endfunction
+
+      try
+        call s:get_dict().foo()
+      catch /my_error/
+        let caught = 'yes'
+      catch
+        let caught = 'no'
+      endtry
+      call assert_equal('yes', caught)
+  END
+  call writefile(lines, 'XtestThrow')
+  source XtestThrow
+
+  call delete('XtestThrow')
+  unlet g:caught
+endfunc
+
+
 " Modeline                                                                 {{{1
 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
index e51df51ffd4a7f79860c32f82e83d4a5e9c12dc4..dc0a939eb6e0098ec3a5af74163d64189bc64a0f 100644 (file)
@@ -5012,7 +5012,7 @@ ex_call(exarg_T *eap)
     clear_evalarg(&evalarg, eap);
 
     // When inside :try we need to check for following "| catch".
-    if (!failed || eap->cstack->cs_trylevel > 0)
+    if (!aborting() && (!failed || eap->cstack->cs_trylevel > 0))
     {
        // Check for trailing illegal characters and a following command.
        arg = skipwhite(arg);
index a349398bfe2f9c83629153b38cd92fc9cc2f360e..c28a302a314cdeaa1584154dc0e1f3c641224a28 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3416,
 /**/
     3415,
 /**/