0
0
mirror of https://github.com/vim/vim.git synced 2025-10-04 05:25:06 -04:00

patch 7.4.2136

Problem:    Closure function fails.
Solution:   Don't reset uf_scoped when it points to another funccal.
This commit is contained in:
Bram Moolenaar
2016-07-31 18:30:22 +02:00
parent 89eaa4185e
commit 5801644819
3 changed files with 81 additions and 50 deletions

View File

@@ -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