0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.1667: local function name cannot shadow a global function name

Problem:    Local function name cannot shadow a global function name.
Solution:   Ignore global functions when checking a script-local or scoped
            function name. (closes #6926)
This commit is contained in:
Bram Moolenaar
2020-09-12 18:32:34 +02:00
parent b00ef0508b
commit 0f769815c8
5 changed files with 82 additions and 19 deletions

View File

@@ -874,6 +874,15 @@ find_func(char_u *name, int is_global, cctx_T *cctx)
return NULL;
}
/*
* Return TRUE if "ufunc" is a global function.
*/
int
func_is_global(ufunc_T *ufunc)
{
return ufunc->uf_name[0] != K_SPECIAL;
}
/*
* Copy the function name of "fp" to buffer "buf".
* "buf" must be able to hold the function name plus three bytes.
@@ -882,7 +891,7 @@ find_func(char_u *name, int is_global, cctx_T *cctx)
static void
cat_func_name(char_u *buf, ufunc_T *fp)
{
if (fp->uf_name[0] == K_SPECIAL)
if (!func_is_global(fp))
{
STRCPY(buf, "<SNR>");
STRCAT(buf, fp->uf_name + 3);