]> granicus.if.org Git - vim/commitdiff
patch 8.2.2481: Vim9: confusing error when variable arguments have default v8.2.2481
authorBram Moolenaar <Bram@vim.org>
Sun, 7 Feb 2021 14:59:49 +0000 (15:59 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 7 Feb 2021 14:59:49 +0000 (15:59 +0100)
Problem:    Vim9: confusing error when variable arguments have a default
            value.
Solution:   Give a specific error message. (closes #7793)

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

index 73ff693fa9659ff6b019ffe29b15f43bd85bbcc6..cdaba5af74094c603d873ac9bcc1a09c8c25948b 100644 (file)
@@ -781,6 +781,16 @@ def Test_call_def_varargs()
       Func(1, 'a')
   END
   CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch')
+
+  lines =<< trim END
+      vim9script
+      def Func(  # some comment
+                ...l = []
+                )
+        echo l
+      enddef
+  END
+  CheckScriptFailure(lines, 'E1160:')
 enddef
 
 let s:value = ''
index e220781b1f7b9fb54ef2d5137998df9d04fd79c2..82df0bb960a48fab761a0d42c7acd8071dfa43af 100644 (file)
@@ -241,6 +241,11 @@ get_function_args(
                                                                         skip);
                if (p == arg)
                    break;
+               if (*skipwhite(p) == '=')
+               {
+                   emsg(_(e_cannot_use_default_for_variable_arguments));
+                   break;
+               }
            }
        }
        else
index 871e04892c877a998a1a204e1e05cabe5255f9f4..c6f44a401fe89eade52626c3ebbf34acdce9f2a2 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2481,
 /**/
     2480,
 /**/