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.
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 4e2f70e..dda812d 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -2557,6 +2557,37 @@
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)