mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.3305: Vim9: :finally in skipped block not handled correctly
Problem: Vim9: :finally in skipped block not handled correctly. Solution: Check whether :finally is in a skipped block. (Naruhiko Nishino, closes #8724)
This commit is contained in:
@@ -2018,7 +2018,8 @@ ex_endtry(exarg_T *eap)
|
||||
{
|
||||
idx = cstack->cs_idx;
|
||||
|
||||
if (in_vim9script()
|
||||
// Check the flags only when not in a skipped block.
|
||||
if (!skip && in_vim9script()
|
||||
&& (cstack->cs_flags[idx] & (CSF_CATCH|CSF_FINALLY)) == 0)
|
||||
{
|
||||
// try/endtry without any catch or finally: give an error and
|
||||
|
@@ -641,6 +641,20 @@ def Test_try_catch_throw()
|
||||
endtry
|
||||
END
|
||||
CheckScriptFailure(lines, 'E1032:')
|
||||
|
||||
# skipping try-finally-endtry when try-finally-endtry is used in another block
|
||||
lines =<< trim END
|
||||
if v:true
|
||||
try
|
||||
finally
|
||||
endtry
|
||||
else
|
||||
try
|
||||
finally
|
||||
endtry
|
||||
endif
|
||||
END
|
||||
CheckDefAndScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
def Test_try_in_catch()
|
||||
|
@@ -755,6 +755,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
3305,
|
||||
/**/
|
||||
3304,
|
||||
/**/
|
||||
|
@@ -8569,6 +8569,8 @@ compile_finally(char_u *arg, cctx_T *cctx)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (cctx->ctx_skip != SKIP_YES)
|
||||
{
|
||||
// End :catch or :finally scope: set value in ISN_TRY instruction
|
||||
isn = ((isn_T *)instr->ga_data) + scope->se_u.se_try.ts_try_label;
|
||||
if (isn->isn_arg.try.try_ref->try_finally != 0)
|
||||
@@ -8612,6 +8614,7 @@ compile_finally(char_u *arg, cctx_T *cctx)
|
||||
return NULL;
|
||||
|
||||
// TODO: set index in ts_finally_label jumps
|
||||
}
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
Reference in New Issue
Block a user