To: vim_dev@googlegroups.com Subject: Patch 8.2.3076 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3076 Problem: Vim9: using try in catch block causes a hang. Solution: Save and restore the ec_in_catch flag. (closes #8478) Files: src/vim9execute.c, src/testdir/test_vim9_script.vim *** ../vim-8.2.3075/src/vim9execute.c 2021-06-23 20:20:49.654780609 +0200 --- src/vim9execute.c 2021-06-30 11:50:47.123940424 +0200 *************** *** 26,31 **** --- 26,32 ---- 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 *************** *** 3166,3171 **** --- 3167,3174 ---- 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 = *************** *** 3263,3271 **** --trystack->ga_len; --trylevel; - ectx->ec_in_catch = FALSE; trycmd = ((trycmd_T *)trystack->ga_data) + trystack->ga_len; if (trycmd->tcd_caught && current_exception != NULL) { // discard the exception --- 3266,3274 ---- --trystack->ga_len; --trylevel; 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 *** ../vim-8.2.3075/src/testdir/test_vim9_script.vim 2021-06-27 15:35:36.955403117 +0200 --- src/testdir/test_vim9_script.vim 2021-06-30 11:55:34.771688825 +0200 *************** *** 605,610 **** --- 605,636 ---- 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 *** ../vim-8.2.3075/src/version.c 2021-06-29 20:36:17.257832714 +0200 --- src/version.c 2021-06-30 11:56:53.847779250 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3076, /**/ -- hundred-and-one symptoms of being an internet addict: 51. You put a pillow case over your laptop so your lover doesn't see it while you are pretending to catch your breath. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///