forked from aniani/vim
patch 9.0.1625: "super" is not considered a reserved name
Problem: "super" is not considered a reserved name. Solution: Add "super" to the list of reserved names. (closes #12515)
This commit is contained in:
parent
5ca05fa59e
commit
ce723f3918
@ -311,6 +311,8 @@ def Test_reserved_name()
|
||||
|
||||
for name in ['true',
|
||||
'false',
|
||||
'this',
|
||||
'super',
|
||||
'null',
|
||||
'null_blob',
|
||||
'null_dict',
|
||||
@ -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()
|
||||
@ -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:')
|
||||
|
@ -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;
|
||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1625,
|
||||
/**/
|
||||
1624,
|
||||
/**/
|
||||
|
@ -1122,6 +1122,7 @@ static char *reserved[] = {
|
||||
"null_string",
|
||||
"null_channel",
|
||||
"null_job",
|
||||
"super",
|
||||
"this",
|
||||
NULL
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user