mirror of
https://github.com/vim/vim.git
synced 2025-09-28 04:24:06 -04:00
patch 8.2.4168: disallowing empty function name breaks existing plugins
Problem: Disallowing empty function name breaks existing plugins. Solution: Allow empty function name in legacy script.
This commit is contained in:
@@ -9,3 +9,7 @@ endfunc
|
|||||||
func foo#addFoo(head)
|
func foo#addFoo(head)
|
||||||
return a:head .. 'foo'
|
return a:head .. 'foo'
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func foo#()
|
||||||
|
return 'empty'
|
||||||
|
endfunc
|
||||||
|
@@ -10,6 +10,9 @@ func Test_autoload_dict_func()
|
|||||||
call assert_equal(1, g:called_foo_bar_echo)
|
call assert_equal(1, g:called_foo_bar_echo)
|
||||||
|
|
||||||
eval 'bar'->g:foo#addFoo()->assert_equal('barfoo')
|
eval 'bar'->g:foo#addFoo()->assert_equal('barfoo')
|
||||||
|
|
||||||
|
" empty name works in legacy script
|
||||||
|
call assert_equal('empty', foo#())
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_source_autoload()
|
func Test_source_autoload()
|
||||||
@@ -23,4 +26,5 @@ func Test_autoload_vim9script()
|
|||||||
call assert_equal(49, auto9#add42(7))
|
call assert_equal(49, auto9#add42(7))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -3693,8 +3693,8 @@ trans_function_name(
|
|||||||
// Note that TFN_ flags use the same values as GLV_ flags.
|
// Note that TFN_ flags use the same values as GLV_ flags.
|
||||||
end = get_lval(start, NULL, &lv, FALSE, skip, flags | GLV_READ_ONLY,
|
end = get_lval(start, NULL, &lv, FALSE, skip, flags | GLV_READ_ONLY,
|
||||||
lead > 2 ? 0 : FNE_CHECK_START);
|
lead > 2 ? 0 : FNE_CHECK_START);
|
||||||
if (end == start
|
if (end == start || (in_vim9script() && end != NULL
|
||||||
|| (end != NULL && end[-1] == AUTOLOAD_CHAR && *end == '('))
|
&& end[-1] == AUTOLOAD_CHAR && *end == '('))
|
||||||
{
|
{
|
||||||
if (!skip)
|
if (!skip)
|
||||||
emsg(_(e_function_name_required));
|
emsg(_(e_function_name_required));
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4168,
|
||||||
/**/
|
/**/
|
||||||
4167,
|
4167,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user