Skip to content

Commit 8314454

Browse files
committed
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)
1 parent 434d72c commit 8314454

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

src/ex_docmd.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3274,10 +3274,10 @@ find_ex_command(
32743274
if (lookup != NULL)
32753275
{
32763276
// Skip over first char for "&opt = val", "$ENV = val" and "@r = val".
3277-
char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$'
3278-
|| *eap->cmd == '@') ? eap->cmd + 1 : eap->cmd;
3277+
char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$')
3278+
? eap->cmd + 1 : eap->cmd;
32793279

3280-
if (vim_strchr((char_u *)"{('[\"", *p) != NULL
3280+
if (vim_strchr((char_u *)"{('[\"@", *p) != NULL
32813281
|| ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL))
32823282
{
32833283
int oplen;
@@ -3336,6 +3336,8 @@ find_ex_command(
33363336
// Recognize an assignment if we recognize the variable name:
33373337
// "g:var = expr"
33383338
// "var = expr" where "var" is a local var name.
3339+
if (*eap->cmd == '@')
3340+
p = eap->cmd + 2;
33393341
oplen = assignment_len(skipwhite(p), &heredoc);
33403342
if (oplen > 0)
33413343
{

src/testdir/test_vim9_script.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,23 @@ def Test_assignment_vim9script()
423423
let ll =
424424
Func()
425425
assert_equal([1, 2], ll)
426+
427+
@/ = 'text'
428+
assert_equal('text', @/)
429+
@0 = 'zero'
430+
assert_equal('zero', @0)
431+
@1 = 'one'
432+
assert_equal('one', @1)
433+
@9 = 'nine'
434+
assert_equal('nine', @9)
435+
@- = 'minus'
436+
assert_equal('minus', @-)
437+
if has('clipboard_working')
438+
@* = 'star'
439+
assert_equal('star', @*)
440+
@+ = 'plus'
441+
assert_equal('plus', @+)
442+
endif
426443
END
427444
CheckScriptSuccess(lines)
428445
enddef

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1359,
757759
/**/
758760
1358,
759761
/**/

0 commit comments

Comments
 (0)