Mercurial > vim
changeset 22625:0afa30d6dc72 v8.2.1861
patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Commit: https://github.com/vim/vim/commit/a2c026d0fd470d68d679616fddfc285cb4834412
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Oct 18 18:03:17 2020 +0200
patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Problem: Vim9: no specific error when parsing lambda fails.
Solution: Also give syntax errors when not evaluating. (closes https://github.com/vim/vim/issues/7154)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 18 Oct 2020 18:15:03 +0200 |
parents | d2b721a599f9 |
children | ea7853a71916 |
files | src/dict.c src/testdir/test_vim9_expr.vim src/version.c |
diffstat | 3 files changed, 20 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dict.c +++ b/src/dict.c @@ -860,13 +860,10 @@ eval_dict(char_u **arg, typval_T *rettv, *arg = skipwhite(*arg); if (**arg != ':') { - if (evaluate) - { - if (*skipwhite(*arg) == ':') - semsg(_(e_no_white_space_allowed_before_str), ":"); - else - semsg(_(e_missing_dict_colon), *arg); - } + if (*skipwhite(*arg) == ':') + semsg(_(e_no_white_space_allowed_before_str), ":"); + else + semsg(_(e_missing_dict_colon), *arg); clear_tv(&tvkey); goto failret; } @@ -899,8 +896,7 @@ eval_dict(char_u **arg, typval_T *rettv, item = dict_find(d, key, -1); if (item != NULL) { - if (evaluate) - semsg(_(e_duplicate_key), key); + semsg(_(e_duplicate_key), key); clear_tv(&tvkey); clear_tv(&tv); goto failret; @@ -937,21 +933,17 @@ eval_dict(char_u **arg, typval_T *rettv, break; if (!had_comma) { - if (evaluate) - { - if (**arg == ',') - semsg(_(e_no_white_space_allowed_before_str), ","); - else - semsg(_(e_missing_dict_comma), *arg); - } + if (**arg == ',') + semsg(_(e_no_white_space_allowed_before_str), ","); + else + semsg(_(e_missing_dict_comma), *arg); goto failret; } } if (**arg != '}') { - if (evaluate) - semsg(_(e_missing_dict_end), *arg); + semsg(_(e_missing_dict_end), *arg); failret: if (d != NULL) dict_free(d);
--- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -1805,6 +1805,13 @@ def Test_expr7_lambda() CheckDefExecFailure(["var s = 'asdf'->{a -> a}('x', 'y')"], 'E1106: 2 arguments too many') CheckDefFailure(["echo 'asdf'->{a -> a}(x)"], 'E1001:', 1) + + CheckDefSuccess(['var Fx = {a -> #{k1: 0,', ' k2: 1}}']) + CheckDefFailure(['var Fx = {a -> #{k1: 0', ' k2: 1}}'], 'E722:', 2) + CheckDefFailure(['var Fx = {a -> #{k1: 0,', ' k2 1}}'], 'E720:', 2) + + CheckDefSuccess(['var Fx = {a -> [0,', ' 1]}']) + CheckDefFailure(['var Fx = {a -> [0', ' 1]}'], 'E696:', 2) enddef def Test_expr7_lambda_vim9script() @@ -2371,7 +2378,7 @@ func Test_expr7_fails() call CheckDefFailure(["'yes'->", "Echo()"], 'E488: Trailing characters: ->', 1) call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2) - call CheckDefExecFailure(["#{a: 1->len()"], 'E488:', 1) + call CheckDefExecFailure(["#{a: 1->len()"], 'E722:', 1) call CheckDefExecFailure(["{'a': 1->len()"], 'E723:', 2) endfunc