]> granicus.if.org Git - vim/commitdiff
patch 8.2.5027: error for missing :endif when an exception was thrown v8.2.5027
authorBram Moolenaar <Bram@vim.org>
Fri, 27 May 2022 12:52:08 +0000 (13:52 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 27 May 2022 12:52:08 +0000 (13:52 +0100)
Problem:    Error for missing :endif when an exception was thrown. (Dani
            Dickstein)
Solution:   Do not give an error when aborting. (closes #10490)

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

index 048c224362c796e378acb0d7b4f399998b965d4f..cbf75059e82ca27004219a52ae5ad3d29222d163 100644 (file)
@@ -1204,7 +1204,8 @@ do_cmdline(
         * In Vim9 script do not give a second error, executing aborts after
         * the first one.
         */
-       if (!got_int && !did_throw && !(did_emsg && in_vim9script())
+       if (!got_int && !did_throw && !aborting()
+               && !(did_emsg && in_vim9script())
                && ((getline_equal(fgetline, cookie, getsourceline)
                        && !source_finished(fgetline, cookie))
                    || (getline_equal(fgetline, cookie, get_func_line)
index 69c7db01ebffb0c4b7a16ba2841e5c0233a08337..aa42205a1b0bc125553c5a1605c9709b52bbca7a 100644 (file)
@@ -2247,6 +2247,23 @@ func Test_user_command_throw_in_function_call()
   unlet g:caught
 endfunc
 
+" Test that after reporting an uncaught exception there is no error for a
+" missing :endif
+func Test_after_exception_no_endif_error()
+  function Throw()
+    throw "Failure"
+  endfunction
+
+  function Foo()
+    if 1
+      call Throw()
+    endif
+  endfunction
+  call assert_fails('call Foo()', ['E605:', 'E605:'])
+  delfunc Throw
+  delfunc Foo
+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
index 47eaf6b2abeb6ba15f543419025342fd3bbf6b1c..3cc224eef2b2f34246cb052515e9f903a7827a65 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5027,
 /**/
     5026,
 /**/