diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-07-31 18:30:22 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-07-31 18:30:22 +0200 |
commit | 580164481924ed8611eb79f0247a0eb1ca0b3b9a (patch) | |
tree | e50e7203296df3899b91e2e1ceec01d115f4798e /src/testdir/test_lambda.vim | |
parent | 89eaa4185efacab253b23a182c1c8a7bbf1096c9 (diff) |
patch 7.4.2136v7.4.2136
Problem: Closure function fails.
Solution: Don't reset uf_scoped when it points to another funccal.
Diffstat (limited to 'src/testdir/test_lambda.vim')
-rw-r--r-- | src/testdir/test_lambda.vim | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/testdir/test_lambda.vim b/src/testdir/test_lambda.vim index 5118738076..4d895460e5 100644 --- a/src/testdir/test_lambda.vim +++ b/src/testdir/test_lambda.vim @@ -247,3 +247,27 @@ function! Test_closure_unlet() call assert_false(has_key(s:foo(), 'x')) call test_garbagecollect_now() endfunction + +function! LambdaFoo() + let x = 0 + function! LambdaBar() closure + let x += 1 + return x + endfunction + return function('LambdaBar') +endfunction + +func Test_closure_refcount() + let g:Count = LambdaFoo() + call test_garbagecollect_now() + call assert_equal(1, g:Count()) + let g:Count2 = LambdaFoo() + call test_garbagecollect_now() + call assert_equal(1, g:Count2()) + call assert_equal(2, g:Count()) + call assert_equal(3, g:Count2()) + + " This causes memory access errors. + " delfunc LambdaFoo + " delfunc LambdaBar +endfunc |