patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Problem: Vim9: cannot use legacy syntax in Vim9 script.
Solution: Add the :legacy command.
diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim
index ad942a8..a0175cd 100644
--- a/src/testdir/test_vim9_assign.vim
+++ b/src/testdir/test_vim9_assign.vim
@@ -1500,33 +1500,33 @@
# OK to define script-local later when prefixed with s:
var lines =<< trim END
def SetLater()
- s:legacy = 'two'
+ s:legvar = 'two'
enddef
defcompile
- let s:legacy = 'one'
+ let s:legvar = 'one'
call SetLater()
- call assert_equal('two', s:legacy)
+ call assert_equal('two', s:legvar)
END
CheckScriptSuccess(lines)
# OK to leave out s: prefix when script-local already defined
lines =<< trim END
- let s:legacy = 'one'
+ let s:legvar = 'one'
def SetNoPrefix()
- legacy = 'two'
+ legvar = 'two'
enddef
call SetNoPrefix()
- call assert_equal('two', s:legacy)
+ call assert_equal('two', s:legvar)
END
CheckScriptSuccess(lines)
# Not OK to leave out s: prefix when script-local defined later
lines =<< trim END
def SetLaterNoPrefix()
- legacy = 'two'
+ legvar = 'two'
enddef
defcompile
- let s:legacy = 'one'
+ let s:legvar = 'one'
END
CheckScriptFailure(lines, 'E476:', 1)
enddef
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 8cfb160..230de20 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -2165,6 +2165,14 @@
assert_match('def <lambda>\d\+(_: any): number\n1 return 0\n enddef', body)
enddef
+def Test_legacy_lambda()
+ legacy echo {x -> 'hello ' .. x}('foo')
+ var lines =<< trim END
+ echo {x -> 'hello ' .. x}('foo')
+ END
+ CheckDefAndScriptFailure(lines, 'E720:')
+enddef
+
def DoFilterThis(a: string): list<string>
# closure nested inside another closure using argument
var Filter = (l) => filter(l, (_, v) => stridx(v, a) == 0)