From: Bram Moolenaar Date: Tue, 23 Nov 2021 14:52:06 +0000 (+0000) Subject: patch 8.2.3656: Vim9: no error for an evironment variable by itself X-Git-Tag: v8.2.3656 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65259b5c6a8ad4edaf6eeb8dbb7b50342c64d403;p=vim patch 8.2.3656: Vim9: no error for an evironment variable by itself Problem: Vim9: no error for an evironment variable by itself. Solution: Give a "without effect" error. (closes #9166) --- diff --git a/src/ex_eval.c b/src/ex_eval.c index 4e38e9649..b3c38a1ea 100644 --- a/src/ex_eval.c +++ b/src/ex_eval.c @@ -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)); diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim index 16f5d55d0..81899d6f0 100644 --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -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() diff --git a/src/version.c b/src/version.c index ea776459e..e47963041 100644 --- a/src/version.c +++ b/src/version.c @@ -757,6 +757,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 3656, /**/ 3655, /**/