0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

patch 8.2.1313: Vim9 script: cannot assign to environment variable

Problem:    Vim9 script: cannot assign to environment variable.
Solution:   Recognize environment variable assignment. (closes #6548)
            Also options and registers.
This commit is contained in:
Bram Moolenaar
2020-07-28 22:38:37 +02:00
parent 066b12e36c
commit b5ed266037
3 changed files with 109 additions and 68 deletions

View File

@@ -61,6 +61,14 @@ def Test_assignment()
assert_equal('foobar', $ENVVAR)
$ENVVAR = ''
let lines =<< trim END
vim9script
$ENVVAR = 'barfoo'
assert_equal('barfoo', $ENVVAR)
$ENVVAR = ''
END
call CheckScriptSuccess(lines)
s:appendToMe ..= 'yyy'
assert_equal('xxxyyy', s:appendToMe)
s:addToMe += 222
@@ -80,6 +88,15 @@ def Test_assignment()
set ts=10
&ts %= 4
assert_equal(2, &ts)
lines =<< trim END
vim9script
&ts = 6
&ts += 3
assert_equal(9, &ts)
END
call CheckScriptSuccess(lines)
call CheckDefFailure(['&notex += 3'], 'E113:')
call CheckDefFailure(['&ts ..= "xxx"'], 'E1019:')
call CheckDefFailure(['&ts = [7]'], 'E1013:')
@@ -106,6 +123,14 @@ def Test_assignment()
call CheckDefFailure(['@a += "more"'], 'E1013:')
call CheckDefFailure(['@a += 123'], 'E1013:')
lines =<< trim END
vim9script
@c = 'areg'
@c ..= 'add'
assert_equal('aregadd', @c)
END
call CheckScriptSuccess(lines)
v:errmsg = 'none'
v:errmsg ..= 'again'
assert_equal('noneagain', v:errmsg)