Patch 8.2.4321
Problem:    Vim9: crash when using a funcref to a closure.
Solution:   Copy pt_outer to the new partial. (closes #9714)
Files:      src/evalfunc.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.4320/src/evalfunc.c      2022-02-05 19:23:14.254442007 +0000
--- src/evalfunc.c      2022-02-07 17:49:03.465744568 +0000
***************
*** 4454,4459 ****
--- 4454,4462 ----
                    pt->pt_name = name;
                    func_ref(name);
                }
+ 
+               if (arg_pt != NULL)
+                   pt->pt_outer = arg_pt->pt_outer;
            }
            rettv->v_type = VAR_PARTIAL;
            rettv->vval.v_partial = pt;
*** ../vim-8.2.4320/src/testdir/test_vim9_func.vim      2022-02-06 
13:54:59.236437901 +0000
--- src/testdir/test_vim9_func.vim      2022-02-07 17:48:27.701797139 +0000
***************
*** 3455,3460 ****
--- 3455,3482 ----
    delete('XnestedDone')
  enddef
  
+ def Test_nested_closure_funcref()
+   var lines =<< trim END
+       vim9script
+       def Func()
+           var n: number
+           def Nested()
+               ++n
+           enddef
+           Nested()
+           g:result_one = n
+           var Ref = function(Nested)
+           Ref()
+           g:result_two = n
+       enddef
+       Func()
+   END
+   v9.CheckScriptSuccess(lines)
+   assert_equal(1, g:result_one)
+   assert_equal(2, g:result_two)
+   unlet g:result_one g:result_two
+ enddef
+ 
  def Test_check_func_arg_types()
    var lines =<< trim END
        vim9script
*** ../vim-8.2.4320/src/version.c       2022-02-07 15:57:46.459385138 +0000
--- src/version.c       2022-02-07 17:44:54.786110273 +0000
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4321,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
24. You realize there is not a sound in the house and you have no idea where
    your children are.

 /// 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/20220207175114.57A751C071D%40moolenaar.net.

Raspunde prin e-mail lui