1
0
forked from aniani/vim

patch 8.2.0703: Vim9: closure cannot store value in outer context

Problem:    Vim9: closure cannot store value in outer context.
Solution:   Make storing value in outer context work.  Make :disassemble
            accept a function reference.
This commit is contained in:
Bram Moolenaar
2020-05-06 21:06:30 +02:00
parent 54ed0dff29
commit b68b346e6d
8 changed files with 97 additions and 9 deletions

View File

@@ -738,6 +738,32 @@ def Test_closure_using_argument()
unlet g:UseVararg
enddef
def MakeGetAndAppendRefs()
let local = 'a'
def Append(arg: string)
local ..= arg
enddef
g:Append = Append
def Get(): string
return local
enddef
g:Get = Get
enddef
def Test_closure_append_get()
MakeGetAndAppendRefs()
assert_equal('a', g:Get())
g:Append('-b')
assert_equal('a-b', g:Get())
g:Append('-c')
assert_equal('a-b-c', g:Get())
unlet g:Append
unlet g:Get
enddef
def Test_nested_closure()
let local = 'text'
def Closure(arg: string): string