Patch 8.2.1482
Problem:    Vim9: crash when using a nested lambda.
Solution:   Do not clear the growarray when not evaluating.  Correct pointer
            when getting the next line. (closes #6731)
Files:      src/eval.c, src/scriptfile.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.1481/src/eval.c  2020-08-18 19:11:34.486104966 +0200
--- src/eval.c  2020-08-18 22:12:10.827248952 +0200
***************
*** 397,404 ****
      int               vim9script = in_vim9script();
      garray_T    *gap = &evalarg->eval_ga;
      int               save_flags = evalarg == NULL ? 0 : evalarg->eval_flags;
  
!     if (vim9script
               && (evalarg->eval_cookie != NULL || evalarg->eval_cctx != NULL))
      {
        ga_init2(gap, sizeof(char_u *), 10);
--- 397,406 ----
      int               vim9script = in_vim9script();
      garray_T    *gap = &evalarg->eval_ga;
      int               save_flags = evalarg == NULL ? 0 : evalarg->eval_flags;
+     int               evaluate = evalarg == NULL
+                              ? FALSE : (evalarg->eval_flags & EVAL_EVALUATE);
  
!     if (vim9script && evaluate
               && (evalarg->eval_cookie != NULL || evalarg->eval_cctx != NULL))
      {
        ga_init2(gap, sizeof(char_u *), 10);
***************
*** 417,423 ****
      if (evalarg != NULL)
        evalarg->eval_flags = save_flags;
  
!     if (vim9script
            && (evalarg->eval_cookie != NULL || evalarg->eval_cctx != NULL))
      {
        if (evalarg->eval_ga.ga_len == 1)
--- 419,425 ----
      if (evalarg != NULL)
        evalarg->eval_flags = save_flags;
  
!     if (vim9script && evaluate
            && (evalarg->eval_cookie != NULL || evalarg->eval_cctx != NULL))
      {
        if (evalarg->eval_ga.ga_len == 1)
***************
*** 5425,5430 ****
--- 5427,5433 ----
                                     && (p[2] == '{' || ASCII_ISALPHA(p[2])))))
        {
            *arg = eval_next_line(evalarg);
+           p = *arg;
            check_white = FALSE;
        }
  
*** ../vim-8.2.1481/src/scriptfile.c    2020-08-15 16:33:24.497747330 +0200
--- src/scriptfile.c    2020-08-18 21:44:11.060253050 +0200
***************
*** 1065,1071 ****
  }
  
  /*
!  * Return the readahead line.
   */
      char_u *
  source_nextline(void *cookie)
--- 1065,1072 ----
  }
  
  /*
!  * Return the readahead line. Note that the pointer may become invalid when
!  * getting the next line, if it's concatenated with the next one.
   */
      char_u *
  source_nextline(void *cookie)
*** ../vim-8.2.1481/src/testdir/test_vim9_expr.vim      2020-08-18 
20:34:09.014182209 +0200
--- src/testdir/test_vim9_expr.vim      2020-08-18 22:28:20.929811667 +0200
***************
*** 1624,1629 ****
--- 1624,1638 ----
        assert_equal(12, v)
    END
    CheckScriptSuccess(lines)
+ 
+   # nested lambda with line breaks
+   lines =<< trim END
+       vim9script
+       search('"', 'cW', 0, 0, {->
+       synstack('.', col('.'))
+       ->map({_, v -> synIDattr(v, 'name')})->len()})
+   END
+   CheckScriptSuccess(lines)
  enddef
  
  def Test_expr7_dict()
*** ../vim-8.2.1481/src/version.c       2020-08-18 20:34:09.014182209 +0200
--- src/version.c       2020-08-18 22:31:26.448747212 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1482,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
236. You start saving URL's in your digital watch.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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/202008182032.07IKWopZ1214997%40masaka.moolenaar.net.

Raspunde prin e-mail lui