Skip to content

Commit

Permalink
patch 9.0.1625: "super" is not considered a reserved name
Browse files Browse the repository at this point in the history
Problem:    "super" is not considered a reserved name.
Solution:   Add "super" to the list of reserved names. (closes #12515)
  • Loading branch information
brammool committed Jun 10, 2023
1 parent 5ca05fa commit ce723f3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
12 changes: 12 additions & 0 deletions src/testdir/test_vim9_assign.vim
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ def Test_reserved_name()

for name in ['true',
'false',
'this',
'super',
'null',
'null_blob',
'null_dict',
Expand All @@ -322,6 +324,15 @@ def Test_reserved_name()
v9.CheckDefExecAndScriptFailure(['var ' .. name .. ' = 0'], 'E1034:')
v9.CheckDefExecAndScriptFailure(['var ' .. name .. ': bool'], 'E1034:')
endfor

var lines =<< trim END
vim9script
def Foo(super: bool)
echo 'something'
enddef
defcompile
END
v9.CheckScriptFailure(lines, 'E1034:')
enddef

def Test_null_values()
Expand Down Expand Up @@ -1526,6 +1537,7 @@ def Test_assignment_failure()
v9.CheckDefFailure(['var false = 1'], 'E1034:')
v9.CheckDefFailure(['var null = 1'], 'E1034:')
v9.CheckDefFailure(['var this = 1'], 'E1034:')
v9.CheckDefFailure(['var super = 1'], 'E1034:')

v9.CheckDefFailure(['[a; b; c] = g:list'], 'E1001:')
v9.CheckDefFailure(['var [a; b; c] = g:list'], 'E1080:')
Expand Down
21 changes: 16 additions & 5 deletions src/userfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,23 @@ one_function_arg(
return arg;
}

// Vim9 script: cannot use script var name for argument. In function: also
// check local vars and arguments.
if (!skip && argtypes != NULL && check_defined(arg, p - arg,
evalarg == NULL ? NULL : evalarg->eval_cctx,
// Extra checks in Vim9 script.
if (!skip && argtypes != NULL)
{
int c = *p;
*p = NUL;
int r = check_reserved_name(arg, FALSE);
*p = c;
if (r == FAIL)
return arg;

// Cannot use script var name for argument. In function: also check
// local vars and arguments.
if (check_defined(arg, p - arg,
evalarg == NULL ? NULL : evalarg->eval_cctx,
eap == NULL ? NULL : eap->cstack, TRUE) == FAIL)
return arg;
return arg;
}

if (newargs != NULL && ga_grow(newargs, 1) == FAIL)
return arg;
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1625,
/**/
1624,
/**/
Expand Down
1 change: 1 addition & 0 deletions src/vim9script.c
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,7 @@ static char *reserved[] = {
"null_string",
"null_channel",
"null_job",
"super",
"this",
NULL
};
Expand Down

0 comments on commit ce723f3

Please sign in to comment.