mirror of
https://github.com/neovim/neovim.git
synced 2026-03-31 21:02:11 +00:00
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 "<SNR>" reference
counted. (closes vim/vim#9916, closes vim/vim#9820)
fb43cfc2c6
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
This commit is contained in:
@@ -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 "<SNR>123_" literally or with K_SPECIAL.
|
||||
/// 2. Numbered functions and lambdas: "<lambda>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".
|
||||
|
||||
Reference in New Issue
Block a user