patch 8.2.3448: :endtry after function call that throws not found
Problem: :endtry after function call that throws not found.
Solution: Do check for following :endtry if an exception is being thrown.
(closes #8889)
diff --git a/src/testdir/test_trycatch.vim b/src/testdir/test_trycatch.vim
index 702d6da..052fab7 100644
--- a/src/testdir/test_trycatch.vim
+++ b/src/testdir/test_trycatch.vim
@@ -2236,7 +2236,7 @@
catch /my_error/
let caught = 'yes'
catch
- let caught = 'no'
+ let caught = v:exception
endtry
call assert_equal('yes', caught)
END
@@ -2247,6 +2247,32 @@
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