To: vim_dev@googlegroups.com Subject: Patch 8.2.2857 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2857 Problem: Vim9: exception in ISN_INSTR caught at wrong level. Solution: Set the starting trylevel in exec_instructions(). (closes #8214) Files: src/vim9compile.c, src/vim9execute.c, src/globals.h, src/testdir/test_vim9_builtin.vim *** ../vim-8.2.2856/src/vim9compile.c 2021-05-09 23:19:17.093003109 +0200 --- src/vim9compile.c 2021-05-16 15:15:52.488955474 +0200 *************** *** 3131,3137 **** s = skipwhite(s); trailing_error = *s != NUL; ! if (expr_res == FAIL || trailing_error) { if (trailing_error) semsg(_(e_trailing_arg), s); --- 3131,3138 ---- s = skipwhite(s); trailing_error = *s != NUL; ! if (expr_res == FAIL || trailing_error ! || ga_grow(&cctx->ctx_instr, 1) == FAIL) { if (trailing_error) semsg(_(e_trailing_arg), s); *************** *** 3185,3191 **** return FAIL; ++*argcount; ! if (is_searchpair && *argcount == 5 && cctx->ctx_instr.ga_len == instr_count + 1) { isn_T *isn = ((isn_T *)cctx->ctx_instr.ga_data) + instr_count; --- 3186,3192 ---- return FAIL; ++*argcount; ! if (is_searchpair && *argcount >= 5 && cctx->ctx_instr.ga_len == instr_count + 1) { isn_T *isn = ((isn_T *)cctx->ctx_instr.ga_data) + instr_count; *** ../vim-8.2.2856/src/vim9execute.c 2021-05-09 23:19:17.093003109 +0200 --- src/vim9execute.c 2021-05-16 15:16:01.504916907 +0200 *************** *** 1295,1300 **** --- 1295,1303 ---- // Start execution at the first instruction. ectx->ec_iidx = 0; + // Only catch exceptions in this instruction list. + ectx->ec_trylevel_at_start = trylevel; + for (;;) { isn_T *iptr; *************** *** 4158,4164 **** ga_init2(&ectx.ec_trystack, sizeof(trycmd_T), 10); ga_init2(&ectx.ec_funcrefs, sizeof(partial_T *), 10); ectx.ec_did_emsg_before = did_emsg_before; - ectx.ec_trylevel_at_start = trylevel; idx = argc - ufunc->uf_args.ga_len; if (idx > 0 && ufunc->uf_va_name == NULL) --- 4161,4166 ---- *** ../vim-8.2.2856/src/globals.h 2021-05-09 23:19:17.089003124 +0200 --- src/globals.h 2021-05-16 15:17:04.484647384 +0200 *************** *** 1616,1622 **** EXTERN char e_invargval[] INIT(= N_("E475: Invalid value for argument %s")); EXTERN char e_invargNval[] INIT(= N_("E475: Invalid value for argument %s: %s")); #ifdef FEAT_EVAL ! EXTERN char e_invexpr2[] INIT(= N_("E15: Invalid expression: %s")); #endif EXTERN char e_invrange[] INIT(= N_("E16: Invalid range")); #if defined(UNIX) || defined(FEAT_SYN_HL) || defined(FEAT_SPELL) --- 1616,1622 ---- EXTERN char e_invargval[] INIT(= N_("E475: Invalid value for argument %s")); EXTERN char e_invargNval[] INIT(= N_("E475: Invalid value for argument %s: %s")); #ifdef FEAT_EVAL ! EXTERN char e_invexpr2[] INIT(= N_("E15: Invalid expression: \"%s\"")); #endif EXTERN char e_invrange[] INIT(= N_("E16: Invalid range")); #if defined(UNIX) || defined(FEAT_SYN_HL) || defined(FEAT_SPELL) *** ../vim-8.2.2856/src/testdir/test_vim9_builtin.vim 2021-05-07 19:44:15.500477283 +0200 --- src/testdir/test_vim9_builtin.vim 2021-05-16 15:22:34.355253740 +0200 *************** *** 1006,1011 **** --- 1006,1025 ---- normal 0f{ assert_equal([0, 0], searchpairpos('{', '', '}', '', 'col(".") > col')) + var lines =<< trim END + vim9script + setline(1, '()') + normal gg + def Fail() + try + searchpairpos('(', '', ')', 'nW', '[0]->map("")') + catch + endtry + enddef + Fail() + END + CheckScriptFailure(lines, 'E15:') + bwipe! enddef *** ../vim-8.2.2856/src/version.c 2021-05-15 23:21:00.799930024 +0200 --- src/version.c 2021-05-16 15:13:46.493494474 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2857, /**/ -- Facepalm statement #6: "Estland is a fantasy place, just like Middle Earth and Madagaskar" /// 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 ///