Patch 8.2.2200
Problem: Vim9: lambda without white space around -> is confusing.
Solution: Require white space in a :def funtion. (issue #7503)
Files: src/vim9compile.c, src/testdir/test_vim9_expr.vim,
src/testdir/test_vim9_disassemble.vim
*** ../vim-8.2.2199/src/vim9compile.c 2020-12-22 18:56:52.055797690 +0100
--- src/vim9compile.c 2020-12-23 20:23:19.102336162 +0100
***************
*** 3915,3928 ****
* Dictionary: {'key': val, 'key': val}
*/
case '{': {
! char_u *start = skipwhite(*arg + 1);
! garray_T ga_arg;
// Find out what comes after the arguments.
! ret = get_function_args(&start, '-', NULL,
&ga_arg, TRUE, NULL, NULL,
TRUE, NULL, NULL);
! if (ret != FAIL && *start == '>')
ret = compile_lambda(arg, cctx);
else
ret = compile_dict(arg, cctx, ppconst);
--- 3915,3933 ----
* Dictionary: {'key': val, 'key': val}
*/
case '{': {
! char_u *start = skipwhite(*arg + 1);
! char_u *after = start;
! garray_T ga_arg;
// Find out what comes after the arguments.
! ret = get_function_args(&after, '-', NULL,
&ga_arg, TRUE, NULL, NULL,
TRUE, NULL, NULL);
! if (ret != FAIL && after[0] == '>'
! && ((after > start + 2
! && VIM_ISWHITE(after[-2]))
! || after == start + 1)
! && IS_WHITE_OR_NUL(after[1]))
ret = compile_lambda(arg, cctx);
else
ret = compile_dict(arg, cctx, ppconst);
*** ../vim-8.2.2199/src/testdir/test_vim9_expr.vim 2020-12-15
21:41:53.141431375 +0100
--- src/testdir/test_vim9_expr.vim 2020-12-23 20:25:07.121990643 +0100
***************
*** 1863,1868 ****
--- 1863,1872 ----
END
CheckDefAndScriptSuccess(lines)
+ CheckDefFailure(["var Ref = {a->a + 1}"], 'E720:')
+ CheckDefFailure(["var Ref = {a-> a + 1}"], 'E720:')
+ CheckDefFailure(["var Ref = {a ->a + 1}"], 'E720:')
+
CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:', 1)
# error is in first line of the lambda
CheckDefFailure(["var L = {a -> a + b}"], 'E1001:', 0)
***************
*** 2538,2544 ****
call CheckDefFailure(["'yes'->", "Echo()"], 'E488: Trailing characters:
->', 1)
call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2)
! call CheckDefExecFailure(["{a: 1->len()"], 'E451:', 1)
call CheckDefExecFailure(["{['a']: 1->len()"], 'E723:', 2)
endfunc
--- 2542,2548 ----
call CheckDefFailure(["'yes'->", "Echo()"], 'E488: Trailing characters:
->', 1)
call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2)
! call CheckDefExecFailure(["{a: 1->len()"], 'E723:', 2)
call CheckDefExecFailure(["{['a']: 1->len()"], 'E723:', 2)
endfunc
*** ../vim-8.2.2199/src/testdir/test_vim9_disassemble.vim 2020-12-21
17:30:46.941668485 +0100
--- src/testdir/test_vim9_disassemble.vim 2020-12-23 20:26:09.673788774
+0100
***************
*** 1541,1550 ****
['{a: 1} is aDict', 'COMPAREDICT is'],
['{a: 1} isnot aDict', 'COMPAREDICT isnot'],
! ['{->33} == {->44}', 'COMPAREFUNC =='],
! ['{->33} != {->44}', 'COMPAREFUNC !='],
! ['{->33} is {->44}', 'COMPAREFUNC is'],
! ['{->33} isnot {->44}', 'COMPAREFUNC isnot'],
['77 == g:xx', 'COMPAREANY =='],
['77 != g:xx', 'COMPAREANY !='],
--- 1541,1550 ----
['{a: 1} is aDict', 'COMPAREDICT is'],
['{a: 1} isnot aDict', 'COMPAREDICT isnot'],
! ['{-> 33} == {-> 44}', 'COMPAREFUNC =='],
! ['{-> 33} != {-> 44}', 'COMPAREFUNC !='],
! ['{-> 33} is {-> 44}', 'COMPAREFUNC is'],
! ['{-> 33} isnot {-> 44}', 'COMPAREFUNC isnot'],
['77 == g:xx', 'COMPAREANY =='],
['77 != g:xx', 'COMPAREANY !='],
*** ../vim-8.2.2199/src/version.c 2020-12-23 18:54:53.569837273 +0100
--- src/version.c 2020-12-23 20:20:16.114910167 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2200,
/**/
--
When a fly lands on the ceiling, does it do a half roll or
a half loop?
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202012231928.0BNJSGCK2976584%40masaka.moolenaar.net.