]> granicus.if.org Git - vim/commitdiff
patch 8.2.4168: disallowing empty function name breaks existing plugins v8.2.4168
authorBram Moolenaar <Bram@vim.org>
Fri, 21 Jan 2022 10:32:58 +0000 (10:32 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 21 Jan 2022 10:32:58 +0000 (10:32 +0000)
Problem:    Disallowing empty function name breaks existing plugins.
Solution:   Allow empty function name in legacy script.

src/testdir/sautest/autoload/foo.vim
src/testdir/test_autoload.vim
src/userfunc.c
src/version.c

index 298e7275d880732fe26540c614d073e3db7b428f..21d33a0f4da77230ba6a8579520c359065ae7b9b 100644 (file)
@@ -9,3 +9,7 @@ endfunc
 func foo#addFoo(head)
   return a:head .. 'foo'
 endfunc
+
+func foo#()
+  return 'empty'
+endfunc
index 384ee1a3286ef65edb7c8f04b526fdc5b9353aee..21de65563df17a0da22d683dd8c7e618b35165ff 100644 (file)
@@ -10,6 +10,9 @@ func Test_autoload_dict_func()
   call assert_equal(1, g:called_foo_bar_echo)
 
   eval 'bar'->g:foo#addFoo()->assert_equal('barfoo')
+
+  " empty name works in legacy script
+  call assert_equal('empty', foo#())
 endfunc
 
 func Test_source_autoload()
@@ -23,4 +26,5 @@ func Test_autoload_vim9script()
   call assert_equal(49, auto9#add42(7))
 endfunc
 
+
 " vim: shiftwidth=2 sts=2 expandtab
index 5de5dd00f205b7271bf07547f5f375381dc74621..223535fdb4fb70fb43eb3dc581d5262b4812097e 100644 (file)
@@ -3693,8 +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
-                  || (end != NULL && end[-1] == AUTOLOAD_CHAR && *end == '('))
+    if (end == start || (in_vim9script() && end != NULL
+                                  && end[-1] == AUTOLOAD_CHAR && *end == '('))
     {
        if (!skip)
            emsg(_(e_function_name_required));
index 27ee162fcf1a01bb9b0fd792de874ce555555089..cea8ece87178f75685f33f6b8aecd010d3f21756 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4168,
 /**/
     4167,
 /**/