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)
diff --git a/src/userfunc.c b/src/userfunc.c
index d5bdadc..d28125f 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -875,6 +875,15 @@
}
/*
+ * 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.
* Takes care of script-local function names.
@@ -882,7 +891,7 @@
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);