1
0
forked from aniani/vim

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)
This commit is contained in:
Bram Moolenaar
2021-01-07 22:03:02 +01:00
parent 43b69b39ac
commit 17126b1396
4 changed files with 120 additions and 61 deletions

View File

@@ -2738,6 +2738,25 @@ parse_command_modifiers(
}
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().