Patch 9.0.1164

3 views
Skip to first unread message

Bram Moolenaar

unread,
Jan 9, 2023, 10:11:17 AM1/9/23
to vim...@googlegroups.com

Patch 9.0.1164
Problem: Evaluating string expression advances function line.
Solution: Disable function lines while parsing a string expression.
(Hirohito Higashi, closes #11796)
Files: src/vim9expr.c, src/testdir/test_vim9_expr.vim


*** ../vim-9.0.1163/src/vim9expr.c 2023-01-04 18:54:05.320172637 +0000
--- src/vim9expr.c 2023-01-09 15:09:56.097603616 +0000
***************
*** 733,739 ****
--- 733,747 ----
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;

*** ../vim-9.0.1163/src/testdir/test_vim9_expr.vim 2022-12-29 20:56:20.025538293 +0000
--- src/testdir/test_vim9_expr.vim 2023-01-09 15:01:28.370349070 +0000
***************
*** 3700,3705 ****
--- 3700,3716 ----
assert_equal('', v:errmsg)
END
v9.CheckScriptSuccess(lines)
+
+ # this was skipping over the expression without an error
+ lines =<< trim END
+ vim9script
+ def Test(s: string): string
+ return substitute(s, 'A', '\=toupper("x")', 'g')
+ ->tolower()
+ enddef
+ assert_equal('xbcd', Test('ABCD'))
+ END
+ v9.CheckScriptSuccess(lines)
enddef

def Test_expr9_method_call_import()
*** ../vim-9.0.1163/src/version.c 2023-01-09 14:18:09.235577964 +0000
--- src/version.c 2023-01-09 15:04:31.610070338 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1164,
/**/

--
I have read and understood the above. X________________

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages