mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Problem: Vim9: error when sourcing script twice and reusing a function name. Solution: Check if the function is dead. (closes #8463)
This commit is contained in:
@@ -1519,6 +1519,27 @@ def Test_vim9script_reload_noclear()
|
|||||||
delete('XExportReload')
|
delete('XExportReload')
|
||||||
delfunc g:Values
|
delfunc g:Values
|
||||||
unlet g:loadCount
|
unlet g:loadCount
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
def Inner()
|
||||||
|
enddef
|
||||||
|
END
|
||||||
|
lines->writefile('XreloadScript.vim')
|
||||||
|
source XreloadScript.vim
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
def Outer()
|
||||||
|
def Inner()
|
||||||
|
enddef
|
||||||
|
enddef
|
||||||
|
defcompile
|
||||||
|
END
|
||||||
|
lines->writefile('XreloadScript.vim')
|
||||||
|
source XreloadScript.vim
|
||||||
|
|
||||||
|
delete('XreloadScript.vim')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_vim9script_reload_import()
|
def Test_vim9script_reload_import()
|
||||||
|
@@ -755,6 +755,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 */
|
||||||
|
/**/
|
||||||
|
3065,
|
||||||
/**/
|
/**/
|
||||||
3064,
|
3064,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -498,8 +498,9 @@ check_defined(char_u *p, size_t len, cctx_T *cctx, int is_arg)
|
|||||||
|| (ufunc = find_func_even_dead(p, FALSE, cctx)) != NULL)
|
|| (ufunc = find_func_even_dead(p, FALSE, cctx)) != NULL)
|
||||||
{
|
{
|
||||||
// A local or script-local function can shadow a global function.
|
// A local or script-local function can shadow a global function.
|
||||||
if (ufunc == NULL || !func_is_global(ufunc)
|
if (ufunc == NULL || ((ufunc->uf_flags & FC_DEAD) == 0
|
||||||
|| (p[0] == 'g' && p[1] == ':'))
|
&& (!func_is_global(ufunc)
|
||||||
|
|| (p[0] == 'g' && p[1] == ':'))))
|
||||||
{
|
{
|
||||||
if (is_arg)
|
if (is_arg)
|
||||||
semsg(_(e_argument_name_shadows_existing_variable_str), p);
|
semsg(_(e_argument_name_shadows_existing_variable_str), p);
|
||||||
|
Reference in New Issue
Block a user