Skip to content

Commit

Permalink
patch 8.2.2660: Vim9: no error for declaration with trailing text
Browse files Browse the repository at this point in the history
Problem:    Vim9: no error for declaration with trailing text.
Solution:   Give an error. (closes #8014)
  • Loading branch information
brammool committed Mar 26, 2021
1 parent c61cb8b commit ccc25aa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/evalvars.c
Expand Up @@ -789,8 +789,11 @@ ex_let(exarg_T *eap)
{
if (vim9script)
{
// Vim9 declaration ":var name: type"
arg = vim9_declare_scriptvar(eap, arg);
if (!ends_excmd2(eap->cmd, skipwhite(argend)))
semsg(_(e_trailing_arg), argend);
else
// Vim9 declaration ":var name: type"
arg = vim9_declare_scriptvar(eap, arg);
}
else
{
Expand Down
9 changes: 8 additions & 1 deletion src/testdir/test_vim9_assign.vim
Expand Up @@ -1290,6 +1290,8 @@ def Test_var_declaration()
other = 1234
g:other_var = other

var xyz: string # comment

# type is inferred
var s:dict = {['a']: 222}
def GetDictVal(key: any)
Expand Down Expand Up @@ -1365,7 +1367,7 @@ def Test_var_declaration_fails()
vim9script
var 9var: string
END
CheckScriptFailure(lines, 'E475:')
CheckScriptFailure(lines, 'E488:')

CheckDefFailure(['var foo.bar = 2'], 'E1087:')
CheckDefFailure(['var foo[3] = 2'], 'E1087:')
Expand Down Expand Up @@ -1617,6 +1619,11 @@ def Test_expr_error_no_assign()
echo x
END
CheckScriptFailureList(lines, ['E1154:', 'E121:'])

lines =<< trim END
var x: string 'string'
END
CheckDefAndScriptFailure(lines, 'E488:')
enddef


Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2660,
/**/
2659,
/**/
Expand Down

0 comments on commit ccc25aa

Please sign in to comment.