From 2ba44af7e05d553770a35e8717c5873458d03706 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 19 Dec 2025 00:55:40 -0500 Subject: [PATCH] vim-patch:8.2.4548: script-local function is deleted when used in a funcref Problem: Script-local function is deleted when used in a funcref. Solution: Do not consider a function starting with "" reference counted. (closes vim/vim#9916, closes vim/vim#9820) https://github.com/vim/vim/commit/fb43cfc2c6a003b850343bfd27cb3059c734d7d4 Co-authored-by: Bram Moolenaar Co-authored-by: zeertzjq --- src/nvim/eval/userfunc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 6c198d061e..ea276459dc 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -1370,14 +1370,16 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett } /// There are two kinds of function names: -/// 1. ordinary names, function defined with :function -/// 2. numbered functions and lambdas +/// 1. ordinary names, function defined with :function; +/// can start with "123_" literally or with K_SPECIAL. +/// 2. Numbered functions and lambdas: "123" /// For the first we only count the name stored in func_hashtab as a reference, /// using function() does not count as a reference, because the function is /// looked up by name. static bool func_name_refcount(const char *name) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE { - return isdigit((uint8_t)(*name)) || *name == '<'; + return isdigit((uint8_t)(*name)) || (name[0] == '<' && name[1] == 'l'); } /// Check the argument count for user function "fp".