diff src/vim9compile.c @ 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 8e1427ac2bce
children c76240efdf02
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -3915,14 +3915,19 @@ compile_expr7(
 	 * Dictionary: {'key': val, 'key': val}
 	 */
 	case '{':   {
-			char_u *start = skipwhite(*arg + 1);
-			garray_T ga_arg;
+			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(&start, '-', NULL,
+			ret = get_function_args(&after, '-', NULL,
 					&ga_arg, TRUE, NULL, NULL,
 							     TRUE, NULL, NULL);
-			if (ret != FAIL && *start == '>')
+			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);