diff src/vim9expr.c @ 31663:2f8a3cde553f v9.0.1164

patch 9.0.1164: evaluating string expression advances function line Commit: https://github.com/vim/vim/commit/01c5f2addf86b8d8940d71c92f6219f14a6df99e Author: h-east <h.east.727@gmail.com> Date: Mon Jan 9 15:10:40 2023 +0000 patch 9.0.1164: evaluating string expression advances function line Problem: Evaluating string expression advances function line. Solution: Disable function lines while parsing a string expression. (Hirohito Higashi, closes #11796)
author Bram Moolenaar <Bram@vim.org>
date Mon, 09 Jan 2023 16:15:03 +0100
parents 5400eba7c3f3
children 2f1af1b2f82d
line wrap: on
line diff
--- a/src/vim9expr.c
+++ b/src/vim9expr.c
@@ -733,7 +733,15 @@ compile_string(isn_T *isn, cctx_T *cctx,
     cctx->ctx_instr.ga_len = 0;
     cctx->ctx_instr.ga_maxlen = 0;
     cctx->ctx_instr.ga_data = NULL;
+
+    // avoid peeking a next line
+    int galen_save = cctx->ctx_ufunc->uf_lines.ga_len;
+    cctx->ctx_ufunc->uf_lines.ga_len = 0;
+
     expr_res = compile_expr0(&s, cctx);
+
+    cctx->ctx_ufunc->uf_lines.ga_len = galen_save;
+
     s = skipwhite(s);
     trailing_error = *s != NUL;