]> granicus.if.org Git - vim/commitdiff
patch 8.2.3645: Vim9: The "no effect" error is not given for all registers v8.2.3645
authorBram Moolenaar <Bram@vim.org>
Mon, 22 Nov 2021 15:05:46 +0000 (15:05 +0000)
committerBram Moolenaar <Bram@vim.org>
Mon, 22 Nov 2021 15:05:46 +0000 (15:05 +0000)
Problem:    Vim9: The "no effect" error is not given for all registers.
Solution:   Include any character following '@'. (closes #8779)

src/ex_eval.c
src/testdir/test_vim9_cmd.vim
src/version.c

index 1f66e336f66a0f7fca0ed6d9e1651bac168db7de..d80500eb0b606982840843a64ace8e0039bf4c95 100644 (file)
@@ -887,22 +887,32 @@ report_discard_pending(int pending, void *value)
     }
 }
 
+/*
+ * Return TRUE if "arg" is only a variable, register or option name.
+ */
     int
 cmd_is_name_only(char_u *arg)
 {
     char_u  *p = arg;
-    char_u  *alias;
+    char_u  *alias = NULL;
     int            name_only = FALSE;
 
-    if (*p == '&')
+    if (*p == '@')
     {
        ++p;
-       if (STRNCMP("l:", p, 2) == 0 || STRNCMP("g:", p, 2) == 0)
-           p += 2;
+       if (*p != NUL)
+           ++p;
+    }
+    else
+    {
+       if (*p == '&')
+       {
+           ++p;
+           if (STRNCMP("l:", p, 2) == 0 || STRNCMP("g:", p, 2) == 0)
+               p += 2;
+       }
+       get_name_len(&p, &alias, FALSE, FALSE);
     }
-    else if (*p == '@')
-       ++p;
-    get_name_len(&p, &alias, FALSE, FALSE);
     name_only = ends_excmd2(arg, skipwhite(p));
     vim_free(alias);
     return name_only;
index 0fa65d1b28b91059885f8fef05acac40bf3df7e7..31f20cb266f5549b389ef18d5776b6afc1621355 100644 (file)
@@ -556,7 +556,34 @@ def Test_use_register()
       @a = 'echo "text"'
       @a
   END
-  CheckDefAndScriptFailure(lines, 'E1207:')
+  CheckDefAndScriptFailure(lines, 'E1207:', 2)
+
+  lines =<< trim END
+      @/ = 'pattern'
+      @/
+  END
+  CheckDefAndScriptFailure(lines, 'E1207:', 2)
+
+  lines =<< trim END
+      &opfunc = 'nothing'
+      &opfunc
+  END
+  CheckDefAndScriptFailure(lines, 'E1207:', 2)
+  &opfunc = ''
+
+  lines =<< trim END
+      &l:showbreak = 'nothing'
+      &l:showbreak
+  END
+  CheckDefAndScriptFailure(lines, 'E1207:', 2)
+  &l:showbreak = ''
+
+  lines =<< trim END
+      &g:showbreak = 'nothing'
+      &g:showbreak
+  END
+  CheckDefAndScriptFailure(lines, 'E1207:', 2)
+  &g:showbreak = ''
 enddef
 
 def Test_environment_use_linebreak()
index 67b26345227e28b3ccbb2e5144fe9ef4f09ad0e7..d91f522a2f8e73685e22f5d4bdb5c417aeec4b8f 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3645,
 /**/
     3644,
 /**/