0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

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

@@ -1464,5 +1464,26 @@ def Test_unlet()
assert_equal('', $ENVVAR)
enddef
def Test_assign_command_modifier()
var lines =<< trim END
var verbose = 0
verbose = 1
assert_equal(1, verbose)
silent verbose = 2
assert_equal(2, verbose)
silent verbose += 2
assert_equal(4, verbose)
silent verbose -= 1
assert_equal(3, verbose)
var topleft = {one: 1}
sandbox topleft.one = 3
assert_equal({one: 3}, topleft)
leftabove topleft[' '] = 4
assert_equal({one: 3, ' ': 4}, topleft)
END
CheckDefAndScriptSuccess(lines)
enddef
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker