summaryrefslogtreecommitdiffstats
path: root/src/ex_eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-07-04 14:47:30 +0200
committerBram Moolenaar <Bram@vim.org>2021-07-04 14:47:30 +0200
commit4197828dc666f2d258594f7f9461534d23cc50e4 (patch)
treef79b33ad12fa19fa6442bd59f0b2b882e58eafb0 /src/ex_eval.c
parent999db2346b61e6f6e6fde2d0b56f4646a46b727d (diff)
patch 8.2.3099: Vim9: missing catch/finally not reported at script levelv8.2.3099
Problem: Vim9: missing catch/finally not reported at script level. Solution: Give an error. (closes #8487)
Diffstat (limited to 'src/ex_eval.c')
-rw-r--r--src/ex_eval.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/ex_eval.c b/src/ex_eval.c
index d68e792449..dac70ab3ac 100644
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -1670,6 +1670,8 @@ ex_catch(exarg_T *eap)
for (idx = cstack->cs_idx; idx > 0; --idx)
if (cstack->cs_flags[idx] & CSF_TRY)
break;
+ if (cstack->cs_flags[idx] & CSF_TRY)
+ cstack->cs_flags[idx] |= CSF_CATCH;
if (cstack->cs_flags[idx] & CSF_FINALLY)
{
// Give up for a ":catch" after ":finally" and ignore it.
@@ -1963,8 +1965,8 @@ ex_endtry(exarg_T *eap)
* made inactive by a ":continue", ":break", ":return", or ":finish" in
* the finally clause. The latter case need not be tested since then
* anything pending has already been discarded. */
- skip = did_emsg || got_int || did_throw ||
- !(cstack->cs_flags[cstack->cs_idx] & CSF_TRUE);
+ skip = did_emsg || got_int || did_throw
+ || !(cstack->cs_flags[cstack->cs_idx] & CSF_TRUE);
if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY))
{
@@ -1992,6 +1994,14 @@ ex_endtry(exarg_T *eap)
{
idx = cstack->cs_idx;
+ if (in_vim9script()
+ && (cstack->cs_flags[idx] & (CSF_CATCH|CSF_FINALLY)) == 0)
+ {
+ // try/endtry without any catch or finally: give an error and
+ // continue.
+ eap->errmsg = _(e_missing_catch_or_finally);
+ }
+
/*
* If we stopped with the exception currently being thrown at this
* try conditional since we didn't know that it doesn't have