diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-13 11:31:04 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-13 11:31:04 +0000 |
commit | 33b968dc60c5fa39451098e680c7559ebc65d1a7 (patch) | |
tree | 0f36bad9cc6a67ddde5408837fc61dc02065e5ef | |
parent | ef082e12df2cafe177b2ac9f6922393223ccf83b (diff) | |
download | vim-git-33b968dc60c5fa39451098e680c7559ebc65d1a7.tar.gz |
patch 8.2.3794: Vim9: cannot find script-local func using "s:"v8.2.3794
Problem: Vim9: cannot find script-local func using "s:". (Yegappan
Lakshmanan)
Solution: Skip the "s:".
-rw-r--r-- | src/testdir/test_vim9_func.vim | 12 | ||||
-rw-r--r-- | src/userfunc.c | 7 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 18 insertions, 3 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 6d098ffda..12a4c5976 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -1243,6 +1243,18 @@ def Test_set_opfunc_to_global_function() &operatorfunc = '' enddef +def Test_use_script_func_name_with_prefix() + var lines =<< trim END + vim9script + func s:Getit() + return 'it' + endfunc + var Fn = s:Getit + assert_equal('it', Fn()) + END + CheckScriptSuccess(lines) +enddef + def Test_lambda_type_allocated() # Check that unreferencing a partial using a lambda can use the variable type # after the lambda has been freed and does not leak memory. diff --git a/src/userfunc.c b/src/userfunc.c index 5f35f35ee..034bf9ef8 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -1885,13 +1885,14 @@ find_func_even_dead(char_u *name, int is_global, cctx_T *cctx) { char_u *after_script = NULL; long sid = 0; - int find_script_local = in_vim9script() - && eval_isnamec1(*name) && name[1] != ':'; + int find_script_local = in_vim9script() && eval_isnamec1(*name) + && (name[1] != ':' || *name == 's'); if (find_script_local) { // Find script-local function before global one. - func = find_func_with_sid(name, current_sctx.sc_sid); + func = find_func_with_sid(name[0] == 's' && name[1] == ':' + ? name + 2 : name, current_sctx.sc_sid); if (func != NULL) return func; } diff --git a/src/version.c b/src/version.c index 971510a5f..c21badce2 100644 --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3794, +/**/ 3793, /**/ 3792, |