]> granicus.if.org Git - vim/commitdiff
patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script v8.2.1359
authorBram Moolenaar <Bram@vim.org>
Sun, 2 Aug 2020 18:40:43 +0000 (20:40 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 2 Aug 2020 18:40:43 +0000 (20:40 +0200)
Problem:    Vim9: cannot assign to / register in Vim9 script.
Solution:   Adjust check for assignment in Vim9 script. (closes #6567)

src/ex_docmd.c
src/testdir/test_vim9_script.vim
src/version.c

index 185fc49cb4bfe86a6540f6c842388fd528acc507..105710b01605b628c12037ae0518bbc66dfec178 100644 (file)
@@ -3274,10 +3274,10 @@ find_ex_command(
     if (lookup != NULL)
     {
        // Skip over first char for "&opt = val", "$ENV = val" and "@r = val".
-       char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$'
-                               || *eap->cmd == '@') ? eap->cmd + 1 : eap->cmd;
+       char_u *pskip = (*eap->cmd == '&' || *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))
        {
            int oplen;
@@ -3336,6 +3336,8 @@ find_ex_command(
            // Recognize an assignment if we recognize the variable name:
            // "g:var = expr"
            // "var = expr"  where "var" is a local var name.
+           if (*eap->cmd == '@')
+               p = eap->cmd + 2;
            oplen = assignment_len(skipwhite(p), &heredoc);
            if (oplen > 0)
            {
index f359a9d9106dc31340a21bb5a2ba25bbd8938530..64ac3bbd925c1bdb5fd27808720ee58b71404061 100644 (file)
@@ -423,6 +423,23 @@ def Test_assignment_vim9script()
     let ll =
           Func()
     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
   CheckScriptSuccess(lines)
 enddef
index 4f1d8a179c933edfdcc2bb1da88654149f6e3301..c169daf8d0c82bd950b75e72ec19d755f74e277b 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1359,
 /**/
     1358,
 /**/