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 <[email protected]> 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 <[email protected]> Signed-off-by: Christian Brabandt <[email protected]> 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); -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wYQ4e-00DBOE-3X%40256bit.org.
