summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-02 18:58:54 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-02 18:58:54 +0200
commit658217276fccb5e53cdf4ba0f023bca80e0a8fed (patch)
treea0aa34fc0291bcae11852949e77342c08b6721b8
parent7226e5b19bd6e081043cbcc32541ef72bbdf667d (diff)
patch 8.2.1357: Vim9: cannot assign to / registerv8.2.1357
Problem: Vim9: cannot assign to / register. Solution: Adjust check for assignment.
-rw-r--r--src/testdir/test_vim9_expr.vim7
-rw-r--r--src/testdir/test_vim9_script.vim3
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c18
4 files changed, 24 insertions, 6 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index ef8797f8f8..584126ff1e 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -1439,6 +1439,13 @@ def Test_expr7_register()
normal axyz
assert_equal("xyz", @.)
+ call CheckDefFailure(["@. = 'yes'"], 'E354:')
+
+ @/ = 'slash'
+ assert_equal('slash', @/)
+
+ @= = 'equal'
+ assert_equal('equal', @=)
enddef
def Test_expr7_namespace()
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 5ed9a3d420..5c2db2ef42 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -470,8 +470,9 @@ def Test_assignment_failure()
call CheckDefFailure(['let $VAR = 5'], 'E1016: Cannot declare an environment variable:')
call CheckScriptFailure(['vim9script', 'let $ENV = "xxx"'], 'E1016:')
- call CheckDefFailure(['let @~ = 5'], 'E354:')
+ call CheckDefFailure(['let @~ = 5'], 'E1066:')
call CheckDefFailure(['let @a = 5'], 'E1066:')
+ call CheckDefFailure(['let @/ = "x"'], 'E1066:')
call CheckScriptFailure(['vim9script', 'let @a = "abc"'], 'E1066:')
call CheckDefFailure(['let g:var = 5'], 'E1016: Cannot declare a global variable:')
diff --git a/src/version.c b/src/version.c
index b04f4feb8d..a9059792da 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1357,
+/**/
1356,
/**/
1355,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index cfd4ff1906..24ef87931b 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -5214,9 +5214,14 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
int has_index = FALSE;
int instr_count = -1;
- p = (*var_start == '&' || *var_start == '$'
- || *var_start == '@') ? var_start + 1 : var_start;
- p = to_name_end(p, TRUE);
+ if (*var_start == '@')
+ p = var_start + 2;
+ else
+ {
+ p = (*var_start == '&' || *var_start == '$')
+ ? var_start + 1 : var_start;
+ p = to_name_end(p, TRUE);
+ }
// "a: type" is declaring variable "a" with a type, not "a:".
if (is_decl && var_end == var_start + 2 && var_end[-1] == ':')
@@ -5279,7 +5284,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
}
else if (*var_start == '@')
{
- if (!valid_yank_reg(var_start[1], TRUE))
+ if (!valid_yank_reg(var_start[1], FALSE) || var_start[1] == '.')
{
emsg_invreg(var_start[1]);
goto theend;
@@ -7247,7 +7252,10 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
int oplen;
int heredoc;
- var_end = find_name_end(pskip, NULL, NULL,
+ if (ea.cmd[0] == '@')
+ var_end = ea.cmd + 2;
+ else
+ var_end = find_name_end(pskip, NULL, NULL,
FNE_CHECK_START | FNE_INCL_BR);
oplen = assignment_len(skipwhite(var_end), &heredoc);
if (oplen > 0)