summaryrefslogtreecommitdiff
path: root/src/vim9compile.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-27 23:08:47 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-27 23:08:47 +0200
commit749639ec7248740cd271f34ec5f7bb70891b459c (patch)
tree88facbb4e5f84b1c84897832fa36f79965168a06 /src/vim9compile.c
parent3988f64f9d512fd809d4a600b020638bf2c7d7ec (diff)
downloadvim-git-749639ec7248740cd271f34ec5f7bb70891b459c.tar.gz
patch 8.2.1529: Vim9: :elseif may be compiled when not neededv8.2.1529
Problem: Vim9: :elseif may be compiled when not needed. Solution: Do evaluate the :elseif expression.
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r--src/vim9compile.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 3e9b42c85..11a75c12c 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -5519,6 +5519,7 @@ compile_elseif(char_u *arg, cctx_T *cctx)
isn_T *isn;
scope_T *scope = cctx->ctx_scope;
ppconst_T ppconst;
+ skip_T save_skip = cctx->ctx_skip;
if (scope == NULL || scope->se_type != IF_SCOPE)
{
@@ -5541,11 +5542,14 @@ compile_elseif(char_u *arg, cctx_T *cctx)
// compile "expr"; if we know it evaluates to FALSE skip the block
CLEAR_FIELD(ppconst);
+ if (cctx->ctx_skip == SKIP_YES)
+ cctx->ctx_skip = SKIP_UNKNOWN;
if (compile_expr1(&p, cctx, &ppconst) == FAIL)
{
clear_ppconst(&ppconst);
return NULL;
}
+ cctx->ctx_skip = save_skip;
if (scope->se_skip_save == SKIP_YES)
clear_ppconst(&ppconst);
else if (instr->ga_len == instr_count && ppconst.pp_used == 1)