mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
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)
This commit is contained in:
parent
d2b98ab4ec
commit
1d34189ecb
@ -2236,7 +2236,7 @@ func Test_user_command_throw_in_function_call()
|
|||||||
catch /my_error/
|
catch /my_error/
|
||||||
let caught = 'yes'
|
let caught = 'yes'
|
||||||
catch
|
catch
|
||||||
let caught = 'no'
|
let caught = v:exception
|
||||||
endtry
|
endtry
|
||||||
call assert_equal('yes', caught)
|
call assert_equal('yes', caught)
|
||||||
END
|
END
|
||||||
@ -2247,6 +2247,32 @@ func Test_user_command_throw_in_function_call()
|
|||||||
unlet g:caught
|
unlet g:caught
|
||||||
endfunc
|
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
|
" Modeline {{{1
|
||||||
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
||||||
|
@ -5011,14 +5011,16 @@ ex_call(exarg_T *eap)
|
|||||||
--emsg_skip;
|
--emsg_skip;
|
||||||
clear_evalarg(&evalarg, eap);
|
clear_evalarg(&evalarg, eap);
|
||||||
|
|
||||||
// When inside :try we need to check for following "| catch".
|
// When inside :try we need to check for following "| catch" or "| endtry".
|
||||||
if (!aborting() && (!failed || eap->cstack->cs_trylevel > 0))
|
// Not when there was an error, but do check if an exception was thrown.
|
||||||
|
if ((!aborting() || did_throw)
|
||||||
|
&& (!failed || eap->cstack->cs_trylevel > 0))
|
||||||
{
|
{
|
||||||
// Check for trailing illegal characters and a following command.
|
// Check for trailing illegal characters and a following command.
|
||||||
arg = skipwhite(arg);
|
arg = skipwhite(arg);
|
||||||
if (!ends_excmd2(eap->arg, arg))
|
if (!ends_excmd2(eap->arg, arg))
|
||||||
{
|
{
|
||||||
if (!failed)
|
if (!failed && !aborting())
|
||||||
{
|
{
|
||||||
emsg_severe = TRUE;
|
emsg_severe = TRUE;
|
||||||
semsg(_(e_trailing_arg), arg);
|
semsg(_(e_trailing_arg), arg);
|
||||||
|
@ -757,6 +757,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3448,
|
||||||
/**/
|
/**/
|
||||||
3447,
|
3447,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user