0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script

Problem:    Vim9: cannot assign to / register in Vim9 script.
Solution:   Adjust check for assignment in Vim9 script. (closes #6567)
This commit is contained in:
Bram Moolenaar
2020-08-02 20:40:43 +02:00
parent 434d72cbf2
commit 8314454648
3 changed files with 24 additions and 3 deletions

View File

@@ -3274,10 +3274,10 @@ find_ex_command(
if (lookup != NULL) if (lookup != NULL)
{ {
// Skip over first char for "&opt = val", "$ENV = val" and "@r = val". // Skip over first char for "&opt = val", "$ENV = val" and "@r = val".
char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$' char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$')
|| *eap->cmd == '@') ? eap->cmd + 1 : eap->cmd; ? eap->cmd + 1 : eap->cmd;
if (vim_strchr((char_u *)"{('[\"", *p) != NULL if (vim_strchr((char_u *)"{('[\"@", *p) != NULL
|| ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL)) || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL))
{ {
int oplen; int oplen;
@@ -3336,6 +3336,8 @@ find_ex_command(
// Recognize an assignment if we recognize the variable name: // Recognize an assignment if we recognize the variable name:
// "g:var = expr" // "g:var = expr"
// "var = expr" where "var" is a local var name. // "var = expr" where "var" is a local var name.
if (*eap->cmd == '@')
p = eap->cmd + 2;
oplen = assignment_len(skipwhite(p), &heredoc); oplen = assignment_len(skipwhite(p), &heredoc);
if (oplen > 0) if (oplen > 0)
{ {

View File

@@ -423,6 +423,23 @@ def Test_assignment_vim9script()
let ll = let ll =
Func() Func()
assert_equal([1, 2], ll) assert_equal([1, 2], ll)
@/ = 'text'
assert_equal('text', @/)
@0 = 'zero'
assert_equal('zero', @0)
@1 = 'one'
assert_equal('one', @1)
@9 = 'nine'
assert_equal('nine', @9)
@- = 'minus'
assert_equal('minus', @-)
if has('clipboard_working')
@* = 'star'
assert_equal('star', @*)
@+ = 'plus'
assert_equal('plus', @+)
endif
END END
CheckScriptSuccess(lines) CheckScriptSuccess(lines)
enddef enddef

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1359,
/**/ /**/
1358, 1358,
/**/ /**/