]> granicus.if.org Git - vim/commitdiff
patch 8.2.1718: Vim9: :def function disallows "firstline" for no good reason v8.2.1718
authorBram Moolenaar <Bram@vim.org>
Sun, 20 Sep 2020 20:04:00 +0000 (22:04 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 20 Sep 2020 20:04:00 +0000 (22:04 +0200)
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)

src/testdir/test_vim9_func.vim
src/userfunc.c
src/version.c

index fe7bf69b856ba3df2f37e819440f39986c6cfbd0..40516509cb7e176cba1fd30a6d1de751e3388628 100644 (file)
@@ -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')
index 595963d628114230b687b421e19afb375f53035c..be2a18c0d688c2f9949feb4421db88de234565e4 100644 (file)
@@ -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);
index dd1934d961ecd4594b6bc478fcd4b440209aa15e..2344ddf2e29476bfe648042667f7add34ca7eb0c 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1718,
 /**/
     1717,
 /**/