summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2023-06-10 19:00:12 +0100
committerBram Moolenaar <Bram@vim.org>2023-06-10 19:00:12 +0100
commitce723f391844695a07d9af02ef60330afd3e158c (patch)
tree2012dc7b8f50b2dadb148da68343c40a18b9a63c
parent5ca05fa59e587f9724306d4788c5dde07fc7225b (diff)
patch 9.0.1625: "super" is not considered a reserved namev9.0.1625
Problem: "super" is not considered a reserved name. Solution: Add "super" to the list of reserved names. (closes #12515)
-rw-r--r--src/testdir/test_vim9_assign.vim12
-rw-r--r--src/userfunc.c21
-rw-r--r--src/version.c2
-rw-r--r--src/vim9script.c1
4 files changed, 31 insertions, 5 deletions
diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim
index 6db2718daf..51a6c6f8d6 100644
--- a/src/testdir/test_vim9_assign.vim
+++ b/src/testdir/test_vim9_assign.vim
@@ -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:')
diff --git a/src/userfunc.c b/src/userfunc.c
index 127588469a..47c3161512 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -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;
diff --git a/src/version.c b/src/version.c
index e8ff7e704b..fa900c1abf 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1625,
+/**/
1624,
/**/
1623,
diff --git a/src/vim9script.c b/src/vim9script.c
index b1849db8e0..a64ce72126 100644
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -1122,6 +1122,7 @@ static char *reserved[] = {
"null_string",
"null_channel",
"null_job",
+ "super",
"this",
NULL
};