patch 9.2.0626: Vim9: illegal characters allowed in dict key names with dot notation
Commit:
https://github.com/vim/vim/commit/85bea0af7efab0eaa6c07abaaadbbaa98f01e3dd
Author: Doug Kearns <
dougk...@gmail.com>
Date: Sat Jun 13 14:57:31 2026 +0000
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 <
dougk...@gmail.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index bd0dca335..1062df185 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 6e78357c4..956304845 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 9d6033464..a041a3e70 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);