Skip to content

Commit

Permalink
patch 8.2.3053: Vim9: cannot assign to @@ in :def function
Browse files Browse the repository at this point in the history
Problem:    Vim9: cannot assign to @@ in :def function
Solution:   Handle '@' like '"'.
  • Loading branch information
brammool committed Jun 26, 2021
1 parent ce024c3 commit 13e45d1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
25 changes: 15 additions & 10 deletions src/testdir/test_vim9_assign.vim
Expand Up @@ -228,16 +228,6 @@ def Test_assignment()
CheckDefFailure(['$SOME_ENV_VAR += "more"'], 'E1051:')
CheckDefFailure(['$SOME_ENV_VAR += 123'], 'E1012:')

lines =<< trim END
@c = 'areg'
@c ..= 'add'
assert_equal('aregadd', @c)
END
CheckDefAndScriptSuccess(lines)

CheckDefFailure(['@a += "more"'], 'E1051:')
CheckDefFailure(['@a += 123'], 'E1012:')

v:errmsg = 'none'
v:errmsg ..= 'again'
assert_equal('noneagain', v:errmsg)
Expand All @@ -249,6 +239,21 @@ def Test_assignment()
END
enddef

def Test_assign_register()
var lines =<< trim END
@c = 'areg'
@c ..= 'add'
assert_equal('aregadd', @c)

@@ = 'some text'
assert_equal('some text', getreg('"'))
END
CheckDefAndScriptSuccess(lines)

CheckDefFailure(['@a += "more"'], 'E1051:')
CheckDefFailure(['@a += 123'], 'E1012:')
enddef

def Test_reserved_name()
for name in ['true', 'false', 'null']
CheckDefExecAndScriptFailure(['var ' .. name .. ' = 0'], 'E1034:')
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -755,6 +755,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3053,
/**/
3052,
/**/
Expand Down
3 changes: 2 additions & 1 deletion src/vim9compile.c
Expand Up @@ -5854,7 +5854,8 @@ get_var_dest(
}
else if (*name == '@')
{
if (!valid_yank_reg(name[1], FALSE) || name[1] == '.')
if (name[1] != '@'
&& (!valid_yank_reg(name[1], FALSE) || name[1] == '.'))
{
emsg_invreg(name[1]);
return FAIL;
Expand Down

0 comments on commit 13e45d1

Please sign in to comment.