neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit ffb45263767d6b1bbbb34a8aedcb24fd26bd0bd1
parent e1aceb0068be6563bad2cbf43e5ee549eddbceef
Author: Jan Edmund Lazo <jan.lazo@mail.utoronto.ca>
Date:   Sat, 20 Dec 2025 00:56:27 -0500

vim-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 vim/vim#6926)

https://github.com/vim/vim/commit/0f769815c82bf93812842e1ad56fcc52c10ff3e5

Co-authored-by: Bram Moolenaar <Bram@vim.org>

Diffstat:
Msrc/nvim/eval/userfunc.c | 12++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c @@ -717,16 +717,24 @@ ufunc_T *find_func(const char *name) return NULL; } +/// @return true if "ufunc" is a global function. +static bool func_is_global(const ufunc_T *ufunc) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE +{ + return (uint8_t)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. -static int cat_func_name(char *buf, size_t bufsize, ufunc_T *fp) +static int cat_func_name(char *buf, size_t bufsize, const ufunc_T *fp) + FUNC_ATTR_NONNULL_ALL { int len = -1; size_t uflen = fp->uf_namelen; assert(uflen > 0); - if ((uint8_t)fp->uf_name[0] == K_SPECIAL && uflen > 3) { + if (!func_is_global(fp) && uflen > 3) { len = snprintf(buf, bufsize, "<SNR>%s", fp->uf_name + 3); } else { len = snprintf(buf, bufsize, "%s", fp->uf_name);