Mercurial > vim
comparison src/testdir/test_vim9_expr.vim @ 23310:7951c5098e8e v8.2.2200
patch 8.2.2200: Vim9: lambda without white space around -> is confusing
Commit: https://github.com/vim/vim/commit/27bf7af9d042b396c412fcad7bac59849a4a420f
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Dec 23 20:27:31 2020 +0100
patch 8.2.2200: Vim9: lambda without white space around -> is confusing
Problem: Vim9: lambda without white space around -> is confusing.
Solution: Require white space in a :def funtion. (issue https://github.com/vim/vim/issues/7503)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 23 Dec 2020 20:30:04 +0100 |
parents | 94608d7c3b55 |
children | c76240efdf02 |
comparison
equal
deleted
inserted
replaced
23309:e0a6d49ed3ad | 23310:7951c5098e8e |
---|---|
1861 var res = map([1, 2, 3], {i: number, v: number -> i + v}) | 1861 var res = map([1, 2, 3], {i: number, v: number -> i + v}) |
1862 assert_equal([1, 3, 5], res) | 1862 assert_equal([1, 3, 5], res) |
1863 END | 1863 END |
1864 CheckDefAndScriptSuccess(lines) | 1864 CheckDefAndScriptSuccess(lines) |
1865 | 1865 |
1866 CheckDefFailure(["var Ref = {a->a + 1}"], 'E720:') | |
1867 CheckDefFailure(["var Ref = {a-> a + 1}"], 'E720:') | |
1868 CheckDefFailure(["var Ref = {a ->a + 1}"], 'E720:') | |
1869 | |
1866 CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:', 1) | 1870 CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:', 1) |
1867 # error is in first line of the lambda | 1871 # error is in first line of the lambda |
1868 CheckDefFailure(["var L = {a -> a + b}"], 'E1001:', 0) | 1872 CheckDefFailure(["var L = {a -> a + b}"], 'E1001:', 0) |
1869 | 1873 |
1870 assert_equal('xxxyyy', 'xxx'->{a, b -> a .. b}('yyy')) | 1874 assert_equal('xxxyyy', 'xxx'->{a, b -> a .. b}('yyy')) |
2536 call CheckDefFailure(["var x = ''", "var y = x.memb"], 'E715:', 2) | 2540 call CheckDefFailure(["var x = ''", "var y = x.memb"], 'E715:', 2) |
2537 | 2541 |
2538 call CheckDefFailure(["'yes'->", "Echo()"], 'E488: Trailing characters: ->', 1) | 2542 call CheckDefFailure(["'yes'->", "Echo()"], 'E488: Trailing characters: ->', 1) |
2539 | 2543 |
2540 call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2) | 2544 call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2) |
2541 call CheckDefExecFailure(["{a: 1->len()"], 'E451:', 1) | 2545 call CheckDefExecFailure(["{a: 1->len()"], 'E723:', 2) |
2542 call CheckDefExecFailure(["{['a']: 1->len()"], 'E723:', 2) | 2546 call CheckDefExecFailure(["{['a']: 1->len()"], 'E723:', 2) |
2543 endfunc | 2547 endfunc |
2544 | 2548 |
2545 let g:Funcrefs = [function('add')] | 2549 let g:Funcrefs = [function('add')] |
2546 | 2550 |