unlet g:caught
enddef
+def Test_try_in_catch()
+ var lines =<< trim END
+ vim9script
+ var seq = []
+ def DoIt()
+ try
+ seq->add('throw 1')
+ eval [][0]
+ seq->add('notreached')
+ catch
+ seq->add('catch')
+ try
+ seq->add('throw 2')
+ eval [][0]
+ seq->add('notreached')
+ catch /nothing/
+ seq->add('notreached')
+ endtry
+ seq->add('done')
+ endtry
+ enddef
+ DoIt()
+ assert_equal(['throw 1', 'catch', 'throw 2', 'done'], seq)
+ END
+enddef
+
" :while at the very start of a function that :continue jumps to
def TryContinueFunc()
while g:Count < 2
typedef struct {
int tcd_frame_idx; // ec_frame_idx at ISN_TRY
int tcd_stack_len; // size of ectx.ec_stack at ISN_TRY
+ int tcd_save_in_catch; // saved ec_in_catch
int tcd_catch_idx; // instruction of the first :catch or :finally
int tcd_finally_idx; // instruction of the :finally block or zero
int tcd_endtry_idx; // instruction of the :endtry
CLEAR_POINTER(trycmd);
trycmd->tcd_frame_idx = ectx->ec_frame_idx;
trycmd->tcd_stack_len = ectx->ec_stack.ga_len;
+ trycmd->tcd_save_in_catch = ectx->ec_in_catch;
+ ectx->ec_in_catch = FALSE;
trycmd->tcd_catch_idx =
iptr->isn_arg.try.try_ref->try_catch;
trycmd->tcd_finally_idx =
--trystack->ga_len;
--trylevel;
- ectx->ec_in_catch = FALSE;
trycmd = ((trycmd_T *)trystack->ga_data)
+ trystack->ga_len;
+ ectx->ec_in_catch = trycmd->tcd_save_in_catch;
if (trycmd->tcd_caught && current_exception != NULL)
{
// discard the exception