From: Doug Kearns Date: Sat, 13 Jun 2026 14:57:31 +0000 (+0000) Subject: patch 9.2.0626: Vim9: illegal characters allowed in dict key names with dot notation X-Git-Tag: v9.2.0626^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=85bea0af7efab0eaa6c07abaaadbbaa98f01e3dd;p=thirdparty%2Fvim.git patch 9.2.0626: Vim9: illegal characters allowed in dict key names with dot notation Problem: In a Vim9 script, colons and hashes are accepted in a dict key name when using dot notation. Solution: Restrict dict key names used with dot notation to alphanumeric and underscore characters, as documented (Doug Kearns). closes: #20507 Signed-off-by: Doug Kearns Signed-off-by: Christian Brabandt --- diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index bd0dca335f..1062df185d 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -3156,6 +3156,10 @@ def Test_expr9_dict() v9.CheckDefFailure(['var x = ({'], 'E723:', 2) v9.CheckScriptFailure(['vim9script', 'var x = ({'], 'E723:', 2) v9.CheckDefExecAndScriptFailure(['{}[getftype("file")]'], 'E716: Key not present in Dictionary: ""', 1) + + # invalid dot notation key name + v9.CheckDefAndScriptFailure(['var x = { "a#b": 1 }', 'x.a#b'], ['E488:', 'E716:'], 2) + v9.CheckDefAndScriptFailure(['var x = { "a:b": 1 }', 'x.a:b'], ['E488:', 'E716:'], 2) enddef def Test_expr9_dict_vim9script() diff --git a/src/version.c b/src/version.c index 6e78357c41..956304845b 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 */ +/**/ + 626, /**/ 625, /**/ diff --git a/src/vim9expr.c b/src/vim9expr.c index 9d6033464c..a041a3e70a 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -2860,9 +2860,8 @@ compile_subscript( return FAIL; } p = *arg; - if (eval_isdictc(*p)) - while (eval_isnamec(*p)) - MB_PTR_ADV(p); + while (eval_isdictc(*p)) + MB_PTR_ADV(p); if (p == *arg) { semsg(_(e_syntax_error_at_str), *arg);