summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-09-20 22:04:00 +0200
committerBram Moolenaar <Bram@vim.org>2020-09-20 22:04:00 +0200
commitb816dae16dbeec91ccb6fd1c0289b86b4ad5d7b3 (patch)
tree2638cb0355920d8e7704abebf99c46501dd1496e
parent809fcecddce59ccb59384d63f5e0505c89f69209 (diff)
downloadvim-git-b816dae16dbeec91ccb6fd1c0289b86b4ad5d7b3.tar.gz
patch 8.2.1718: Vim9: :def function disallows "firstline" for no good reasonv8.2.1718
Problem: Vim9: :def function disallows "firstline" and "lastline" argument names for no good reason. Solution: Don't check the arguments for a :def function. (closes #6986)
-rw-r--r--src/testdir/test_vim9_func.vim9
-rw-r--r--src/userfunc.c5
-rw-r--r--src/version.c2
3 files changed, 14 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index fe7bf69b8..40516509c 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -486,6 +486,15 @@ def Test_assign_to_argument()
CheckScriptFailure(['def Func(arg: number)', 'arg = 3', 'enddef', 'defcompile'], 'E1090:')
enddef
+" These argument names are reserved in legacy functions.
+def WithReservedNames(firstline: string, lastline: string): string
+ return firstline .. lastline
+enddef
+
+def Test_argument_names()
+ assert_equal('OK', WithReservedNames('O', 'K'))
+enddef
+
def Test_call_func_defined_later()
g:DefinedLater('one')->assert_equal('one')
assert_fails('NotDefined("one")', 'E117:', '', 2, 'Test_call_func_defined_later')
diff --git a/src/userfunc.c b/src/userfunc.c
index 595963d62..be2a18c0d 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -66,8 +66,9 @@ one_function_arg(char_u *arg, garray_T *newargs, garray_T *argtypes, int skip)
while (ASCII_ISALNUM(*p) || *p == '_')
++p;
if (arg == p || isdigit(*arg)
- || (p - arg == 9 && STRNCMP(arg, "firstline", 9) == 0)
- || (p - arg == 8 && STRNCMP(arg, "lastline", 8) == 0))
+ || (argtypes == NULL
+ && ((p - arg == 9 && STRNCMP(arg, "firstline", 9) == 0)
+ || (p - arg == 8 && STRNCMP(arg, "lastline", 8) == 0))))
{
if (!skip)
semsg(_("E125: Illegal argument: %s"), arg);
diff --git a/src/version.c b/src/version.c
index dd1934d96..2344ddf2e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1718,
+/**/
1717,
/**/
1716,