From 17a836cbee6b8d8ff555f8e307f48a779908db41 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 12 Aug 2020 17:35:58 +0200 Subject: [PATCH] patch 8.2.1429: Vim9: no error for missing white after : in dict Problem: Vim9: no error for missing white after : in dict. Solution: Check for white space. (closes #6671) Also check that there is no white before the :. --- src/testdir/test_vim9_expr.vim | 4 ++++ src/testdir/test_vim9_func.vim | 2 +- src/version.c | 2 ++ src/vim9compile.c | 13 ++++++++++--- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 3d1605356..a942dd4de 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -1494,6 +1494,10 @@ def Test_expr7_dict() mixed = #{a: 234} mixed = #{} + call CheckDefFailure(["let x = #{a:8}"], 'E1069:') + call CheckDefFailure(["let x = #{a : 8}"], 'E1068:') + call CheckDefFailure(["let x = #{a :8}"], 'E1068:') + call CheckDefFailure(["let x = #{8: 8}"], 'E1014:') call CheckDefFailure(["let x = #{xxx}"], 'E720:') call CheckDefFailure(["let x = #{xxx: 1", "let y = 2"], 'E722:') diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 24078f56e..1f9768ff9 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -774,7 +774,7 @@ func Test_InternalFuncRetType() enddef def RetListAny(): list - return items({'k' : 'v'}) + return items({'k': 'v'}) enddef def RetListString(): list diff --git a/src/version.c b/src/version.c index 46d027d14..b290fdcb1 100644 --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1429, /**/ 1428, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index dfcff508f..502c66f37 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -2593,14 +2593,21 @@ compile_dict(char_u **arg, cctx_T *cctx, int literal) } } - *arg = skipwhite(*arg); if (**arg != ':') { - semsg(_(e_missing_dict_colon), *arg); + if (*skipwhite(*arg) == ':') + semsg(_(e_no_white_before), ":"); + else + semsg(_(e_missing_dict_colon), *arg); return FAIL; } - whitep = *arg + 1; + if (!IS_WHITE_OR_NUL(*whitep)) + { + semsg(_(e_white_after), ":"); + return FAIL; + } + *arg = skipwhite(*arg + 1); if (may_get_next_line(whitep, arg, cctx) == FAIL) { -- 2.50.1