diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-03-11 18:54:17 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-03-11 18:54:17 +0000 |
commit | fb43cfc2c6a003b850343bfd27cb3059c734d7d4 (patch) | |
tree | 3fcc51a6f034d757087b3b67c15ad3645e1031da /src/userfunc.c | |
parent | f52fac2ed94e6acc9612103c6c6f55660cc695c8 (diff) | |
download | vim-git-fb43cfc2c6a003b850343bfd27cb3059c734d7d4.tar.gz |
patch 8.2.4548: script-local function is deleted when used in a funcrefv8.2.4548
Problem: Script-local function is deleted when used in a funcref.
Solution: Do not consider a function starting with "<SNR>" reference
counted. (closes #9916, closes #9820)
Diffstat (limited to 'src/userfunc.c')
-rw-r--r-- | src/userfunc.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/userfunc.c b/src/userfunc.c index 42e1e89bc..6a5d84bfd 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -2215,8 +2215,9 @@ numbered_function(char_u *name) /* * There are two kinds of function names: - * 1. ordinary names, function defined with :function or :def - * 2. numbered functions and lambdas + * 1. ordinary names, function defined with :function or :def; + * 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. @@ -2224,7 +2225,7 @@ numbered_function(char_u *name) int func_name_refcount(char_u *name) { - return numbered_function(name) || *name == '<'; + return numbered_function(name) || (name[0] == '<' && name[1] == 'l'); } /* |