Skip to content

Commit b816dae

Browse files
committed
patch 8.2.1718: Vim9: :def function disallows "firstline" for no good reason
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)
1 parent 809fcec commit b816dae

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/testdir/test_vim9_func.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,15 @@ def Test_assign_to_argument()
486486
CheckScriptFailure(['def Func(arg: number)', 'arg = 3', 'enddef', 'defcompile'], 'E1090:')
487487
enddef
488488

489+
" These argument names are reserved in legacy functions.
490+
def WithReservedNames(firstline: string, lastline: string): string
491+
return firstline .. lastline
492+
enddef
493+
494+
def Test_argument_names()
495+
assert_equal('OK', WithReservedNames('O', 'K'))
496+
enddef
497+
489498
def Test_call_func_defined_later()
490499
g:DefinedLater('one')->assert_equal('one')
491500
assert_fails('NotDefined("one")', 'E117:', '', 2, 'Test_call_func_defined_later')

src/userfunc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ one_function_arg(char_u *arg, garray_T *newargs, garray_T *argtypes, int skip)
6666
while (ASCII_ISALNUM(*p) || *p == '_')
6767
++p;
6868
if (arg == p || isdigit(*arg)
69-
|| (p - arg == 9 && STRNCMP(arg, "firstline", 9) == 0)
70-
|| (p - arg == 8 && STRNCMP(arg, "lastline", 8) == 0))
69+
|| (argtypes == NULL
70+
&& ((p - arg == 9 && STRNCMP(arg, "firstline", 9) == 0)
71+
|| (p - arg == 8 && STRNCMP(arg, "lastline", 8) == 0))))
7172
{
7273
if (!skip)
7374
semsg(_("E125: Illegal argument: %s"), arg);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1718,
753755
/**/
754756
1717,
755757
/**/

0 commit comments

Comments
 (0)