]> granicus.if.org Git - vim/commitdiff
patch 8.2.4163: no error for omitting function name after autoload prefix v8.2.4163
authorBram Moolenaar <Bram@vim.org>
Thu, 20 Jan 2022 19:38:46 +0000 (19:38 +0000)
committerBram Moolenaar <Bram@vim.org>
Thu, 20 Jan 2022 19:38:46 +0000 (19:38 +0000)
Problem:    No error for omitting function name after autoload prefix.
Solution:   Check for missing function name. (issue #9577)

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

index c26ccf80aa71b5ef0f77079481019bc9100f6c4a..b15d411c87c28a0e03fc9cdb112e9986961be3fd 100644 (file)
@@ -1514,6 +1514,21 @@ def Test_vim9script_autoload_duplicate()
   delete('Xdir', 'rf')
 enddef
 
+def Test_autoload_missing_function_name()
+  mkdir('Xdir/autoload', 'p')
+
+  var lines =<< trim END
+     vim9script
+
+     def loadme#()
+     enddef
+  END
+  writefile(lines, 'Xdir/autoload/loadme.vim')
+  assert_fails('source Xdir/autoload/loadme.vim', 'E129:')
+
+  delete('Xdir', 'rf')
+enddef
+
 def Test_import_autoload_postponed()
   mkdir('Xdir/autoload', 'p')
   var save_rtp = &rtp
index 014ec5524387497e0a71d7aca6306dc7660afaf2..680017ca76c42bcdf38e57876cf11e0af88f53fc 100644 (file)
@@ -3693,7 +3693,8 @@ trans_function_name(
     // Note that TFN_ flags use the same values as GLV_ flags.
     end = get_lval(start, NULL, &lv, FALSE, skip, flags | GLV_READ_ONLY,
                                              lead > 2 ? 0 : FNE_CHECK_START);
-    if (end == start)
+    if (end == start
+                  || (end != NULL && end[-1] == AUTOLOAD_CHAR && *end == '('))
     {
        if (!skip)
            emsg(_(e_function_name_required));
index 7fd24f5eea0b68629bb2c2243673dda812e0a9f9..2dd019443a8cbfbe2f2be069cf348dab4beaf689 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4163,
 /**/
     4162,
 /**/