Mercurial > vim
diff src/testdir/test_vim9_func.vim @ 20257:683c2da4982b v8.2.0684
patch 8.2.0684: Vim9: memory leak when using lambda
Commit: https://github.com/vim/vim/commit/f7779c63d4fe531e2483502d4441f24802342768
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 3 15:38:16 2020 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 03 May 2020 15:45:05 +0200 |
parents | aac52c32a91f |
children | 350bb78345ba |
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -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: st 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