Patch 8.2.1434
Problem:    Vim9: crash when lambda uses outer function argument.
Solution:   Set the flag that the outer context is used.
Files:      src/vim9compile.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.1433/src/vim9compile.c   2020-08-12 19:15:30.380192349 +0200
--- src/vim9compile.c   2020-08-12 19:38:45.133721436 +0200
***************
*** 2135,2141 ****
--- 2135,2144 ----
        if (gen_load)
            res = generate_LOAD(cctx, ISN_LOAD, idx, NULL, type);
        if (gen_load_outer)
+       {
            res = generate_LOAD(cctx, ISN_LOADOUTER, idx, NULL, type);
+           cctx->ctx_outer_used = TRUE;
+       }
      }
  
      *arg = end;
*** ../vim-8.2.1433/src/testdir/test_vim9_expr.vim      2020-08-12 
19:15:30.380192349 +0200
--- src/testdir/test_vim9_expr.vim      2020-08-12 19:41:03.889045718 +0200
***************
*** 1443,1448 ****
--- 1443,1458 ----
          }
  enddef
  
+ def LambdaUsingArg(x: number): func
+   return {->
+             # some comment
+             x == 1
+             # some comment
+             ||
+             x == 2
+         }
+ enddef
+ 
  def Test_expr7_lambda()
    let La = { -> 'result'}
    assert_equal('result', La())
***************
*** 1481,1486 ****
--- 1491,1499 ----
    assert_equal(true, LambdaWithComments()(2))
    assert_equal(false, LambdaWithComments()(3))
  
+   assert_equal(false, LambdaUsingArg(0)())
+   assert_equal(true, LambdaUsingArg(1)())
+ 
    call CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:')
  enddef
  
*** ../vim-8.2.1433/src/version.c       2020-08-12 19:15:30.380192349 +0200
--- src/version.c       2020-08-12 19:41:32.316906830 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1434,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
184. You no longer ask prospective dates what their sign is, instead
     your line is "Hi, what's your URL?"

 /// 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/202008121742.07CHgRN3115744%40masaka.moolenaar.net.

Raspunde prin e-mail lui