]> granicus.if.org Git - vim/commitdiff
patch 8.2.3656: Vim9: no error for an evironment variable by itself v8.2.3656
authorBram Moolenaar <Bram@vim.org>
Tue, 23 Nov 2021 14:52:06 +0000 (14:52 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 23 Nov 2021 14:52:06 +0000 (14:52 +0000)
Problem:    Vim9: no error for an evironment variable by itself.
Solution:   Give a "without effect" error. (closes #9166)

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

index 4e38e964917742184f4113a2f66a34ecf1b3f066..b3c38a1ea57dca587b262f669c370ef50eb4d0f5 100644 (file)
@@ -888,7 +888,8 @@ report_discard_pending(int pending, void *value)
 }
 
 /*
- * Return TRUE if "arg" is only a variable, register or option name.
+ * Return TRUE if "arg" is only a variable, register, environment variable or
+ * option name.
  */
     int
 cmd_is_name_only(char_u *arg)
@@ -911,6 +912,8 @@ cmd_is_name_only(char_u *arg)
            if (STRNCMP("l:", p, 2) == 0 || STRNCMP("g:", p, 2) == 0)
                p += 2;
        }
+       else if (*p == '$')
+           ++p;
        get_name_len(&p, &alias, FALSE, FALSE);
     }
     name_only = ends_excmd2(arg, skipwhite(p));
index 16f5d55d045af4295022559a366b10b35f99c9fd..81899d6f00edfbf713a9242072b75e413beb3939 100644 (file)
@@ -584,6 +584,13 @@ def Test_use_register()
   END
   CheckDefAndScriptFailure(lines, 'E1207:', 2)
   &g:showbreak = ''
+
+  lines =<< trim END
+      $SomeEnv = 'value'
+      $SomeEnv
+  END
+  CheckDefAndScriptFailure(lines, 'E1207:', 2)
+  $SomeEnv = ''
 enddef
 
 def Test_environment_use_linebreak()
index ea776459e8b2aec34cb268063f72ac8964e43a33..e47963041b43f18ca12eab003107a91ca0fa825a 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3656,
 /**/
     3655,
 /**/