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 -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230109151110.EB2F71C044B%40moolenaar.net.

Raspunde prin e-mail lui