summaryrefslogtreecommitdiff
path: root/src/vim9compile.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-02-05 22:10:05 +0100
committerBram Moolenaar <Bram@vim.org>2020-02-05 22:10:05 +0100
commitff80cb6807d99db35cc928f151b87503b2928e19 (patch)
tree89d0ce116546e4fd5a6a3a0d8600d927024ca090 /src/vim9compile.c
parenta78e9c61a0ded9c5302bc77e889aa1b3d3467f61 (diff)
downloadvim-git-ff80cb6807d99db35cc928f151b87503b2928e19.tar.gz
patch 8.2.0216: several Vim9 instructions are not testedv8.2.0216
Problem: Several Vim9 instructions are not tested. Solution: Add more tests. Fix :disassamble output. Make catch with pattern work.
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r--src/vim9compile.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 117bfd291..12400a35d 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -4369,13 +4369,33 @@ compile_catch(char_u *arg, cctx_T *cctx UNUSED)
}
else
{
+ char_u *end;
+ char_u *pat;
+ char_u *tofree = NULL;
+ size_t len;
+
// Push v:exception, push {expr} and MATCH
generate_instr_type(cctx, ISN_PUSHEXC, &t_string);
- if (compile_expr1(&p, cctx) == FAIL)
- return NULL;
+ end = skip_regexp(p + 1, *p, TRUE, &tofree);
+ if (*end != *p)
+ {
+ semsg(_("E1067: Separator mismatch: %s"), p);
+ vim_free(tofree);
+ return FAIL;
+ }
+ if (tofree == NULL)
+ len = end - (p + 1);
+ else
+ len = end - (tofree + 1);
+ pat = vim_strnsave(p + 1, len);
+ vim_free(tofree);
+ p += len + 2;
+ if (pat == NULL)
+ return FAIL;
+ if (generate_PUSHS(cctx, pat) == FAIL)
+ return FAIL;
- // TODO: check for strings?
if (generate_COMPARE(cctx, EXPR_MATCH, FALSE) == FAIL)
return NULL;