]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0626: Vim9: illegal characters allowed in dict key names with dot notation v9.2.0626
authorDoug Kearns <dougkearns@gmail.com>
Sat, 13 Jun 2026 14:57:31 +0000 (14:57 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 13 Jun 2026 14:57:31 +0000 (14:57 +0000)
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 <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_vim9_expr.vim
src/version.c
src/vim9expr.c

index bd0dca335f9a68d8af0293675435505daab1ae35..1062df185d54cf8516f2de7dce6275959b82b2ad 100644 (file)
@@ -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()
index 6e78357c41b3df8882e5e820a52a48efff5394cf..956304845bc01a80a5e7d111eaa91e91ff42ee26 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    626,
 /**/
     625,
 /**/
index 9d6033464c31030765a24463ca8a123d9044c3f7..a041a3e70a65a2ab80a022ab7dbf64149e5c557f 100644 (file)
@@ -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);