summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-05-16 15:24:49 +0200
committerBram Moolenaar <Bram@vim.org>2021-05-16 15:24:49 +0200
commitff65288aa89dcd50760ad942d58baff70c6e93e6 (patch)
tree9ec3a52625bdaa6fd6ec635a9390e22ae1b6afed
parent3ec3217f0491e9ba8aa8ea02f7e454cd19a287ef (diff)
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong levelv8.2.2857
Problem: Vim9: exception in ISN_INSTR caught at wrong level. Solution: Set the starting trylevel in exec_instructions(). (closes #8214)
-rw-r--r--src/globals.h2
-rw-r--r--src/testdir/test_vim9_builtin.vim14
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c5
-rw-r--r--src/vim9execute.c4
5 files changed, 23 insertions, 4 deletions
diff --git a/src/globals.h b/src/globals.h
index 0a6b87a780..74a7c3967f 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -1616,7 +1616,7 @@ EXTERN char e_duparg2[] INIT(= N_("E983: Duplicate argument: %s"));
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"));
+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)
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index 41063c5444..2e9e0566c1 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -1006,6 +1006,20 @@ def Test_searchpair()
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
diff --git a/src/version.c b/src/version.c
index 70e02ed8ed..e45d3be709 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2857,
+/**/
2856,
/**/
2855,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 39c36dfb24..9aa93de7b2 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -3131,7 +3131,8 @@ compile_string(isn_T *isn, cctx_T *cctx)
s = skipwhite(s);
trailing_error = *s != NUL;
- if (expr_res == FAIL || trailing_error)
+ if (expr_res == FAIL || trailing_error
+ || ga_grow(&cctx->ctx_instr, 1) == FAIL)
{
if (trailing_error)
semsg(_(e_trailing_arg), s);
@@ -3185,7 +3186,7 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount, int is_searchpair)
return FAIL;
++*argcount;
- if (is_searchpair && *argcount == 5
+ 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;
diff --git a/src/vim9execute.c b/src/vim9execute.c
index ae4142b0ce..425cdb9bb2 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -1295,6 +1295,9 @@ exec_instructions(ectx_T *ectx)
// 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,7 +4161,6 @@ call_def_function(
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)