patch 7.4.2143
Problem: A funccal is garbage collected while it can still be used.
Solution: Set copyID in all referenced functions. Do not list lambda
functions with ":function".
diff --git a/src/testdir/test_lambda.vim b/src/testdir/test_lambda.vim
index 1df1f1c..901d535 100644
--- a/src/testdir/test_lambda.vim
+++ b/src/testdir/test_lambda.vim
@@ -270,3 +270,17 @@
delfunc LambdaFoo
delfunc LambdaBar
endfunc
+
+func Test_named_function_closure()
+ func! Afoo()
+ let x = 14
+ func! s:Abar() closure
+ return x
+ endfunc
+ call assert_equal(14, s:Abar())
+ endfunc
+ call Afoo()
+ call assert_equal(14, s:Abar())
+ call test_garbagecollect_now()
+ call assert_equal(14, s:Abar())
+endfunc