1
0
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:
Bram Moolenaar
2021-09-13 18:25:54 +02:00
parent 28e591dd50
commit b1b6f4de2b
6 changed files with 226 additions and 26 deletions

View File

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