Mercurial > vim
diff src/testdir/test_vim9_assign.vim @ 23537:7f0fc2ab90e3 v8.2.2311
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Commit: https://github.com/vim/vim/commit/17126b13969c3b91516a8e9ff80fb6a1f6924d40
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 7 22:03:02 2021 +0100
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 07 Jan 2021 22:15:05 +0100 |
parents | f39a18a42aed |
children | 4156f972efb1 |
line wrap: on
line diff
--- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -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