Skip to content

Commit 36f691f

Browse files
committed
patch 8.2.3416: second error is reported while exception is being thrown
Problem: Second error is reported while exception is being thrown. Solution: Do not check for trailing characters when already aborting. (closes #8842)
1 parent fc3b775 commit 36f691f

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/testdir/test_trycatch.vim

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,5 +2224,29 @@ func Test_user_command_try_catch()
22242224
unlet g:caught
22252225
endfunc
22262226

2227+
" Test for using throw in a called function with following error {{{1
2228+
func Test_user_command_throw_in_function_call()
2229+
let lines =<< trim END
2230+
function s:get_dict() abort
2231+
throw 'my_error'
2232+
endfunction
2233+
2234+
try
2235+
call s:get_dict().foo()
2236+
catch /my_error/
2237+
let caught = 'yes'
2238+
catch
2239+
let caught = 'no'
2240+
endtry
2241+
call assert_equal('yes', caught)
2242+
END
2243+
call writefile(lines, 'XtestThrow')
2244+
source XtestThrow
2245+
2246+
call delete('XtestThrow')
2247+
unlet g:caught
2248+
endfunc
2249+
2250+
22272251
" Modeline {{{1
22282252
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker

src/userfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5012,7 +5012,7 @@ ex_call(exarg_T *eap)
50125012
clear_evalarg(&evalarg, eap);
50135013

50145014
// When inside :try we need to check for following "| catch".
5015-
if (!failed || eap->cstack->cs_trylevel > 0)
5015+
if (!aborting() && (!failed || eap->cstack->cs_trylevel > 0))
50165016
{
50175017
// Check for trailing illegal characters and a following command.
50185018
arg = skipwhite(arg);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3416,
758760
/**/
759761
3415,
760762
/**/

0 commit comments

Comments
 (0)