forked from aniani/vim
patch 8.2.3435: Vim9: dict is not passed to dict function
Problem: Vim9: dict is not passed to dict function. Solution: Keep the dict used until a function call.
This commit is contained in:
@@ -2557,6 +2557,37 @@ def Test_legacy_errors()
|
||||
endfor
|
||||
enddef
|
||||
|
||||
def Test_call_legacy_with_dict()
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
func Legacy() dict
|
||||
let g:result = self.value
|
||||
endfunc
|
||||
def TestDirect()
|
||||
var d = {value: 'yes', func: Legacy}
|
||||
d.func()
|
||||
enddef
|
||||
TestDirect()
|
||||
assert_equal('yes', g:result)
|
||||
unlet g:result
|
||||
|
||||
def TestIndirect()
|
||||
var d = {value: 'foo', func: Legacy}
|
||||
var Fi = d.func
|
||||
Fi()
|
||||
enddef
|
||||
TestIndirect()
|
||||
assert_equal('foo', g:result)
|
||||
unlet g:result
|
||||
|
||||
var d = {value: 'bar', func: Legacy}
|
||||
d.func()
|
||||
assert_equal('bar', g:result)
|
||||
unlet g:result
|
||||
END
|
||||
CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
def DoFilterThis(a: string): list<string>
|
||||
# closure nested inside another closure using argument
|
||||
var Filter = (l) => filter(l, (_, v) => stridx(v, a) == 0)
|
||||
|
||||
Reference in New Issue
Block a user