Patch 8.2.3775
Problem:    Vim9: lambda compiled without outer context when debugging.
Solution:   When compiling a lambda for debugging also compile it without.
            (closes #9302)
Files:      src/vim9compile.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.3774/src/vim9compile.c   2021-12-09 14:23:40.261634977 +0000
--- src/vim9compile.c   2021-12-10 16:54:38.163348804 +0000
***************
*** 3762,3773 ****
        ufunc->uf_ret_type = &t_unknown;
      compile_def_function(ufunc, FALSE, cctx->ctx_compile_type, cctx);
  
  #ifdef FEAT_PROFILE
!     // When the outer function is compiled for profiling, the lambda may be
!     // called without profiling.  Compile it here in the right context.
!     if (cctx->ctx_compile_type == CT_PROFILE)
!       compile_def_function(ufunc, FALSE, CT_NONE, cctx);
  #endif
  
      // The last entry in evalarg.eval_tofree_ga is a copy of the last line and
      // "*arg" may point into it.  Point into the original line to avoid a
--- 3762,3776 ----
        ufunc->uf_ret_type = &t_unknown;
      compile_def_function(ufunc, FALSE, cctx->ctx_compile_type, cctx);
  
+     // When the outer function is compiled for profiling or debugging, the
+     // lambda may be called without profiling or debugging.  Compile it here 
in
+     // the right context.
+     if (cctx->ctx_compile_type == CT_DEBUG
  #ifdef FEAT_PROFILE
!           || cctx->ctx_compile_type == CT_PROFILE
  #endif
+        )
+       compile_def_function(ufunc, FALSE, CT_NONE, cctx);
  
      // The last entry in evalarg.eval_tofree_ga is a copy of the last line and
      // "*arg" may point into it.  Point into the original line to avoid a
*** ../vim-8.2.3774/src/testdir/test_vim9_script.vim    2021-12-05 
17:20:20.426818196 +0000
--- src/testdir/test_vim9_script.vim    2021-12-10 16:53:37.263436799 +0000
***************
*** 4634,4639 ****
--- 4634,4662 ----
    CheckDefExecAndScriptFailure(lines, 'some error continued', 1)
  enddef
  
+ def Test_debug_with_lambda()
+   CheckRunVimInTerminal
+ 
+   var lines =<< trim END
+       vim9script
+       def Func()
+         var n = 0
+         echo [0]->filter((_, v) => v == n)
+       enddef
+       breakadd func Func
+       Func()
+   END
+   writefile(lines, 'XdebugFunc')
+   var buf = RunVimInTerminal('-S XdebugFunc', {rows: 6, wait_for_ruler: 0})
+   WaitForAssert(() => assert_match('^>', term_getline(buf, 6)))
+ 
+   term_sendkeys(buf, "cont\<CR>")
+   WaitForAssert(() => assert_match('\[0\]', term_getline(buf, 5)))
+ 
+   StopVimInTerminal(buf)
+   delete('XdebugFunc')
+ enddef
+ 
  def ProfiledWithLambda()
    var n = 3
    echo [[1, 2], [3, 4]]->filter((_, l) => l[0] == n)
*** ../vim-8.2.3774/src/version.c       2021-12-10 13:40:05.060213928 +0000
--- src/version.c       2021-12-10 16:38:21.396810980 +0000
***************
*** 755,756 ****
--- 755,758 ----
  {   /* Add new patch number below this line */
+ /**/
+     3775,
  /**/

-- 
Far out in the uncharted backwaters of the unfashionable end of the
Western Spiral arm of the Galaxy lies a small unregarded yellow sun.
Orbiting this at a distance of roughly ninety-eight million miles is an
utterly insignificant little blue-green planet whose ape-descended life
forms are so amazingly primitive that they still think digital watches
are a pretty neat idea ...
                -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

 /// 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/20211210165625.DEB591C09BB%40moolenaar.net.

Raspunde prin e-mail lui