diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-05-17 00:01:42 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-05-17 00:01:42 +0200 |
commit | 3b1373b193ce5fbf25e852277a4ecc98688c7bb8 (patch) | |
tree | 5d8343ef3e9a3ecac8618b4846fc24fec7d50797 /src/testdir | |
parent | 1764faa38645a559172e9a31f08447385835de81 (diff) | |
download | vim-git-3b1373b193ce5fbf25e852277a4ecc98688c7bb8.tar.gz |
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statementv8.2.2861
Problem: Vim9: "legacy return" is not recognized as a return statement.
Solution: Specifically check for a return command. (closes #8213)
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_vim9_expr.vim | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 718db8b70..fe5de29d0 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -2777,6 +2777,10 @@ def Test_expr7_negate_add() CheckDefAndScriptFailure(lines, 'E15:') enddef +def LegacyReturn(): string + legacy return #{key: 'ok'}.key +enddef + def Test_expr7_legacy_script() var lines =<< trim END let s:legacy = 'legacy' @@ -2790,6 +2794,17 @@ def Test_expr7_legacy_script() call assert_equal('legacy', GetLocalPrefix()) END CheckScriptSuccess(lines) + + assert_equal('ok', LegacyReturn()) + + lines =<< trim END + vim9script + def GetNumber(): number + legacy return range(3)->map('v:val + 1') + enddef + echo GetNumber() + END + CheckScriptFailure(lines, 'E1012: Type mismatch; expected number but got list<number>') enddef def Echo(arg: any): string |