patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Problem: Vim9: cannot assign to a variable that shadows a command modifier.
Solution: Check for assignment after possible command modifier.
(closes #7632)
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 5a3a37a..9659c20 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2738,6 +2738,25 @@
}
p = skip_range(eap->cmd, TRUE, NULL);
+
+ // In Vim9 script a variable can shadow a command modifier:
+ // verbose = 123
+ // verbose += 123
+ // silent! verbose = func()
+ // verbose.member = 2
+ // verbose[expr] = 2
+ if (in_vim9script())
+ {
+ char_u *s;
+
+ for (s = p; ASCII_ISALPHA(*s); ++s)
+ ;
+ s = skipwhite(s);
+ if (vim_strchr((char_u *)".[=", *s) != NULL
+ || (*s != NUL && s[1] == '='))
+ break;
+ }
+
switch (*p)
{
// When adding an entry, also modify cmd_exists().