diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-04-10 20:10:26 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-04-10 20:10:26 +0200 |
commit | bb8a7ce0a1bcfafca715275dbadc2ead612f82dd (patch) | |
tree | 34aa8a00426226114caa1be454c3e10e520ba223 /src/testdir | |
parent | 87795939d01932b0d8155fd69c7494fa51c523f3 (diff) |
patch 8.2.2747: Vim9: not always an error for too many function argumentsv8.2.2747
Problem: Vim9: not always an error for too many function arguments.
Solution: Check for getting too many arguments.
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 4 | ||||
-rw-r--r-- | src/testdir/test_vim9_func.vim | 15 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index f537eef82c..5c13d51277 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -506,7 +506,7 @@ def Test_filter_wrong_dict_key_type() enddef def Test_filter_return_type() - var l = filter([1, 2, 3], () => 1) + var l = filter([1, 2, 3], (_, _) => 1) var res = 0 for n in l res += n @@ -516,7 +516,7 @@ enddef def Test_filter_missing_argument() var dict = {aa: [1], ab: [2], ac: [3], de: [4]} - var res = dict->filter((k) => k =~ 'a' && k !~ 'b') + var res = dict->filter((k, _) => k =~ 'a' && k !~ 'b') res->assert_equal({aa: [1], ac: [3]}) enddef diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index c02a324d4c..6b353dd699 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -2102,7 +2102,7 @@ def Test_script_var_in_lambda() var lines =<< trim END vim9script var script = 'test' - assert_equal(['test'], map(['one'], () => script)) + assert_equal(['test'], map(['one'], (_, _) => script)) END CheckScriptSuccess(lines) enddef @@ -2355,7 +2355,7 @@ def Test_block_scoped_var() var x = ['a', 'b', 'c'] if 1 var y = 'x' - map(x, () => y) + map(x, (_, _) => y) endif var z = x assert_equal(['x', 'x', 'x'], z) @@ -2654,6 +2654,17 @@ def Test_ignored_argument() CheckDefAndScriptFailure(lines, 'E1181:', 1) enddef +def Test_too_many_arguments() + var lines =<< trim END + echo [0, 1, 2]->map(() => 123) + END + CheckDefExecAndScriptFailure(lines, 'E1106: 2 arguments too many', 1) + + lines =<< trim END + echo [0, 1, 2]->map((_) => 123) + END + CheckDefExecAndScriptFailure(lines, 'E1106: One argument too many', 1) +enddef " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |