mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 8.2.4264: Vim9: can use old style autoload function name
Problem: Vim9: can use old style autoload function name. Solution: Give an error for old style autoload function name.
This commit is contained in:
@@ -3218,8 +3218,8 @@ EXTERN char e_cannot_import_dot_vim_without_using_as[]
|
|||||||
INIT(= N_("E1261: Cannot import .vim without using \"as\""));
|
INIT(= N_("E1261: Cannot import .vim without using \"as\""));
|
||||||
EXTERN char e_cannot_import_same_script_twice_str[]
|
EXTERN char e_cannot_import_same_script_twice_str[]
|
||||||
INIT(= N_("E1262: Cannot import the same script twice: %s"));
|
INIT(= N_("E1262: Cannot import the same script twice: %s"));
|
||||||
EXTERN char e_using_autoload_name_in_non_autoload_script_str[]
|
EXTERN char e_cannot_use_name_with_hash_in_vim9_script_use_export_instead[]
|
||||||
INIT(= N_("E1263: Using autoload name in a non-autoload script: %s"));
|
INIT(= N_("E1263: cannot use name with # in Vim9 script, use export instead"));
|
||||||
EXTERN char e_autoload_import_cannot_use_absolute_or_relative_path[]
|
EXTERN char e_autoload_import_cannot_use_absolute_or_relative_path[]
|
||||||
INIT(= N_("E1264: Autoload import cannot use absolute or relative path: %s"));
|
INIT(= N_("E1264: Autoload import cannot use absolute or relative path: %s"));
|
||||||
EXTERN char e_cannot_use_partial_here[]
|
EXTERN char e_cannot_use_partial_here[]
|
||||||
|
@@ -46,7 +46,7 @@ def TestCompilingErrorInTry()
|
|||||||
|
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
def script#OnlyCompiled()
|
export def OnlyCompiled()
|
||||||
g:runtime = 'yes'
|
g:runtime = 'yes'
|
||||||
invalid
|
invalid
|
||||||
enddef
|
enddef
|
||||||
@@ -114,7 +114,7 @@ def Test_autoload_name_mismatch()
|
|||||||
|
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
def scriptX#Function()
|
export def NoFunction()
|
||||||
# comment
|
# comment
|
||||||
g:runtime = 'yes'
|
g:runtime = 'yes'
|
||||||
enddef
|
enddef
|
||||||
@@ -126,7 +126,7 @@ def Test_autoload_name_mismatch()
|
|||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
call script#Function()
|
call script#Function()
|
||||||
END
|
END
|
||||||
v9.CheckScriptFailure(lines, 'E746:', 2)
|
v9.CheckScriptFailure(lines, 'E117:', 1)
|
||||||
|
|
||||||
&rtp = save_rtp
|
&rtp = save_rtp
|
||||||
delete(dir, 'rf')
|
delete(dir, 'rf')
|
||||||
|
@@ -1614,13 +1614,13 @@ enddef
|
|||||||
def Test_vim9_autoload_full_name()
|
def Test_vim9_autoload_full_name()
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
def some#gettest(): string
|
export def Gettest(): string
|
||||||
return 'test'
|
return 'test'
|
||||||
enddef
|
enddef
|
||||||
g:some#name = 'name'
|
g:some#name = 'name'
|
||||||
g:some#dict = {key: 'value'}
|
g:some#dict = {key: 'value'}
|
||||||
|
|
||||||
def some#varargs(a1: string, ...l: list<string>): string
|
export def Varargs(a1: string, ...l: list<string>): string
|
||||||
return a1 .. l[0] .. l[1]
|
return a1 .. l[0] .. l[1]
|
||||||
enddef
|
enddef
|
||||||
END
|
END
|
||||||
@@ -1630,23 +1630,23 @@ def Test_vim9_autoload_full_name()
|
|||||||
var save_rtp = &rtp
|
var save_rtp = &rtp
|
||||||
exe 'set rtp^=' .. getcwd() .. '/Xdir'
|
exe 'set rtp^=' .. getcwd() .. '/Xdir'
|
||||||
|
|
||||||
assert_equal('test', g:some#gettest())
|
assert_equal('test', g:some#Gettest())
|
||||||
assert_equal('name', g:some#name)
|
assert_equal('name', g:some#name)
|
||||||
assert_equal('value', g:some#dict.key)
|
assert_equal('value', g:some#dict.key)
|
||||||
g:some#other = 'other'
|
g:some#other = 'other'
|
||||||
assert_equal('other', g:some#other)
|
assert_equal('other', g:some#other)
|
||||||
|
|
||||||
assert_equal('abc', some#varargs('a', 'b', 'c'))
|
assert_equal('abc', some#Varargs('a', 'b', 'c'))
|
||||||
|
|
||||||
# upper case script name works
|
# upper case script name works
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
def Other#getOther(): string
|
export def GetOther(): string
|
||||||
return 'other'
|
return 'other'
|
||||||
enddef
|
enddef
|
||||||
END
|
END
|
||||||
writefile(lines, 'Xdir/autoload/Other.vim')
|
writefile(lines, 'Xdir/autoload/Other.vim')
|
||||||
assert_equal('other', g:Other#getOther())
|
assert_equal('other', g:Other#GetOther())
|
||||||
|
|
||||||
delete('Xdir', 'rf')
|
delete('Xdir', 'rf')
|
||||||
&rtp = save_rtp
|
&rtp = save_rtp
|
||||||
@@ -2020,14 +2020,23 @@ enddef
|
|||||||
|
|
||||||
def Test_autoload_name_wrong()
|
def Test_autoload_name_wrong()
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
vim9script
|
|
||||||
def Xscriptname#Func()
|
def Xscriptname#Func()
|
||||||
enddef
|
enddef
|
||||||
END
|
END
|
||||||
writefile(lines, 'Xscriptname.vim')
|
writefile(lines, 'Xscriptname.vim')
|
||||||
v9.CheckScriptFailure(lines, 'E1263:')
|
v9.CheckScriptFailure(lines, 'E746:')
|
||||||
|
|
||||||
delete('Xscriptname.vim')
|
delete('Xscriptname.vim')
|
||||||
|
|
||||||
|
mkdir('Xdir/autoload', 'p')
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
def somescript#Func()
|
||||||
|
enddef
|
||||||
|
END
|
||||||
|
writefile(lines, 'Xdir/autoload/somescript.vim')
|
||||||
|
assert_fails('source Xdir/autoload/somescript.vim', 'E1263:')
|
||||||
|
|
||||||
|
delete('Xdir', 'rf')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_import_autoload_postponed()
|
def Test_import_autoload_postponed()
|
||||||
@@ -2202,7 +2211,7 @@ def Test_vim9_autoload_disass()
|
|||||||
|
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
def debugit#test(): string
|
export def Test(): string
|
||||||
return 'debug'
|
return 'debug'
|
||||||
enddef
|
enddef
|
||||||
END
|
END
|
||||||
@@ -2210,7 +2219,7 @@ def Test_vim9_autoload_disass()
|
|||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
def profileit#test(): string
|
export def Test(): string
|
||||||
return 'profile'
|
return 'profile'
|
||||||
enddef
|
enddef
|
||||||
END
|
END
|
||||||
@@ -2218,10 +2227,10 @@ def Test_vim9_autoload_disass()
|
|||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
assert_equal('debug', debugit#test())
|
assert_equal('debug', debugit#Test())
|
||||||
disass debugit#test
|
disass debugit#Test
|
||||||
assert_equal('profile', profileit#test())
|
assert_equal('profile', profileit#Test())
|
||||||
disass profileit#test
|
disass profileit#Test
|
||||||
END
|
END
|
||||||
v9.CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
|
||||||
@@ -2233,7 +2242,7 @@ enddef
|
|||||||
def Test_vim9_aucmd_autoload()
|
def Test_vim9_aucmd_autoload()
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
def foo#test()
|
export def Test()
|
||||||
echomsg getreg('"')
|
echomsg getreg('"')
|
||||||
enddef
|
enddef
|
||||||
END
|
END
|
||||||
@@ -2243,7 +2252,7 @@ def Test_vim9_aucmd_autoload()
|
|||||||
var save_rtp = &rtp
|
var save_rtp = &rtp
|
||||||
exe 'set rtp^=' .. getcwd() .. '/Xdir'
|
exe 'set rtp^=' .. getcwd() .. '/Xdir'
|
||||||
augroup test
|
augroup test
|
||||||
autocmd TextYankPost * call foo#test()
|
autocmd TextYankPost * call foo#Test()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
normal Y
|
normal Y
|
||||||
|
@@ -3078,7 +3078,7 @@ def Test_error_in_autoload_script()
|
|||||||
|
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
vim9script noclear
|
vim9script noclear
|
||||||
def script#autoloaded()
|
export def Autoloaded()
|
||||||
enddef
|
enddef
|
||||||
def Broken()
|
def Broken()
|
||||||
var x: any = ''
|
var x: any = ''
|
||||||
@@ -3091,7 +3091,7 @@ def Test_error_in_autoload_script()
|
|||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
def CallAutoloaded()
|
def CallAutoloaded()
|
||||||
script#autoloaded()
|
script#Autoloaded()
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
function Legacy()
|
function Legacy()
|
||||||
@@ -3196,7 +3196,7 @@ func Test_no_redraw_when_restoring_cpo()
|
|||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
def script#func()
|
export def Func()
|
||||||
enddef
|
enddef
|
||||||
END
|
END
|
||||||
call mkdir('Xdir/autoload', 'p')
|
call mkdir('Xdir/autoload', 'p')
|
||||||
@@ -3206,7 +3206,7 @@ func Test_no_redraw_when_restoring_cpo()
|
|||||||
vim9script
|
vim9script
|
||||||
set cpo+=M
|
set cpo+=M
|
||||||
exe 'set rtp^=' .. getcwd() .. '/Xdir'
|
exe 'set rtp^=' .. getcwd() .. '/Xdir'
|
||||||
au CmdlineEnter : ++once timer_start(0, (_) => script#func())
|
au CmdlineEnter : ++once timer_start(0, (_) => script#Func())
|
||||||
setline(1, 'some text')
|
setline(1, 'some text')
|
||||||
END
|
END
|
||||||
call writefile(lines, 'XTest_redraw_cpo')
|
call writefile(lines, 'XTest_redraw_cpo')
|
||||||
|
@@ -4232,6 +4232,11 @@ define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free)
|
|||||||
name = prefixed;
|
name = prefixed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (vim9script && vim_strchr(name, AUTOLOAD_CHAR) != NULL)
|
||||||
|
{
|
||||||
|
emsg(_(e_cannot_use_name_with_hash_in_vim9_script_use_export_instead));
|
||||||
|
goto ret_free;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// An error in a function call during evaluation of an expression in magic
|
// An error in a function call during evaluation of an expression in magic
|
||||||
@@ -4540,12 +4545,6 @@ define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (vim9script && vim_strchr(name, AUTOLOAD_CHAR) != NULL)
|
|
||||||
{
|
|
||||||
semsg(_(e_using_autoload_name_in_non_autoload_script_str),
|
|
||||||
name);
|
|
||||||
goto erret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (var_conflict)
|
if (var_conflict)
|
||||||
{
|
{
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
4264,
|
||||||
/**/
|
/**/
|
||||||
4263,
|
4263,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user