Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
23309:e0a6d49ed3ad | 23310:7951c5098e8e |
---|---|
3913 /* | 3913 /* |
3914 * Lambda: {arg, arg -> expr} | 3914 * Lambda: {arg, arg -> expr} |
3915 * Dictionary: {'key': val, 'key': val} | 3915 * Dictionary: {'key': val, 'key': val} |
3916 */ | 3916 */ |
3917 case '{': { | 3917 case '{': { |
3918 char_u *start = skipwhite(*arg + 1); | 3918 char_u *start = skipwhite(*arg + 1); |
3919 garray_T ga_arg; | 3919 char_u *after = start; |
3920 garray_T ga_arg; | |
3920 | 3921 |
3921 // Find out what comes after the arguments. | 3922 // Find out what comes after the arguments. |
3922 ret = get_function_args(&start, '-', NULL, | 3923 ret = get_function_args(&after, '-', NULL, |
3923 &ga_arg, TRUE, NULL, NULL, | 3924 &ga_arg, TRUE, NULL, NULL, |
3924 TRUE, NULL, NULL); | 3925 TRUE, NULL, NULL); |
3925 if (ret != FAIL && *start == '>') | 3926 if (ret != FAIL && after[0] == '>' |
3927 && ((after > start + 2 | |
3928 && VIM_ISWHITE(after[-2])) | |
3929 || after == start + 1) | |
3930 && IS_WHITE_OR_NUL(after[1])) | |
3926 ret = compile_lambda(arg, cctx); | 3931 ret = compile_lambda(arg, cctx); |
3927 else | 3932 else |
3928 ret = compile_dict(arg, cctx, ppconst); | 3933 ret = compile_dict(arg, cctx, ppconst); |
3929 } | 3934 } |
3930 break; | 3935 break; |