0
0
mirror of https://github.com/vim/vim.git synced 2025-10-18 07:54:29 -04:00

patch 8.2.0684: Vim9: memory leak when using lambda

Problem:    Vim9: memory leak when using lambda.
Solution:   Move the funccal context to the partial. Free the function when
            exiting.
This commit is contained in:
Bram Moolenaar
2020-05-03 15:38:16 +02:00
parent 5adc55cb74
commit f7779c63d4
7 changed files with 83 additions and 71 deletions

View File

@@ -680,13 +680,6 @@ def Test_closure_two_refs()
unlet g:Read
enddef
" TODO: fix memory leak when using same function again.
def MakeTwoRefs_2()
let local = ['some']
g:Extend = {s -> local->add(s)}
g:Read = {-> local}
enddef
def ReadRef(Ref: func(): list<string>): string
return join(Ref(), ' ')
enddef
@@ -696,7 +689,7 @@ def ExtendRef(Ref: func(string), add: string)
enddef
def Test_closure_two_indirect_refs()
MakeTwoRefs_2()
MakeTwoRefs()
assert_equal('some', ReadRef(g:Read))
ExtendRef(g:Extend, 'more')
assert_equal('some more', ReadRef(g:Read))
@@ -707,4 +700,5 @@ def Test_closure_two_indirect_refs()
unlet g:Read
enddef
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker