aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-01-16 09:27:08 +0800
committerzeertzjq <zeertzjq@outlook.com>2025-01-16 11:17:14 +0800
commitf8680d009741d01e137aeb2232aa7e033cd70d7b (patch)
tree38a864a0005e055eb4f4a40809b0dda85d83cecc
parent718e16536052c0e75de61a32ef237a9e87fc03f2 (diff)
downloadrneovim-f8680d009741d01e137aeb2232aa7e033cd70d7b.tar.gz
rneovim-f8680d009741d01e137aeb2232aa7e033cd70d7b.tar.bz2
rneovim-f8680d009741d01e137aeb2232aa7e033cd70d7b.zip
vim-patch:9.1.1013: Vim9: Regression caused by patch v9.1.0646
Problem: Vim9: Regression caused by patch v9.1.0646 Solution: Translate the function name before invoking it in call() (Yegappan Lakshmanan) fixes: vim/vim#16430 closes: vim/vim#16445 https://github.com/vim/vim/commit/6289f9159102e0855bedc566636b5e7ca6ced72c N/A patch: vim-patch:8.2.4176: Vim9: cannot use imported function with call() Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
-rw-r--r--src/nvim/errors.h1
-rw-r--r--src/nvim/eval/funcs.c15
-rw-r--r--src/nvim/eval/userfunc.c1
-rw-r--r--test/functional/vimscript/ctx_functions_spec.lua7
-rw-r--r--test/old/testdir/test_user_func.vim2
5 files changed, 18 insertions, 8 deletions
diff --git a/src/nvim/errors.h b/src/nvim/errors.h
index df94945a3d..baea005f15 100644
--- a/src/nvim/errors.h
+++ b/src/nvim/errors.h
@@ -129,6 +129,7 @@ EXTERN const char e_missingparen[] INIT(= N_("E107: Missing parentheses: %s"));
EXTERN const char e_empty_buffer[] INIT(= N_("E749: Empty buffer"));
EXTERN const char e_nobufnr[] INIT(= N_("E86: Buffer %" PRId64 " does not exist"));
+EXTERN const char e_unknown_function_str[] INIT(= N_("E117: Unknown function: %s"));
EXTERN const char e_str_not_inside_function[] INIT(= N_("E193: %s not inside a function"));
EXTERN const char e_invalpat[] INIT(= N_("E682: Invalid search pattern or delimiter"));
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index ed3efca0d7..0d2653ef21 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -575,22 +575,29 @@ static void f_call(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (func == NULL || *func == NUL) {
return; // type error, empty name or null function
}
+ char *p = func;
+ char *tofree = trans_function_name(&p, false, TFN_INT|TFN_QUIET, NULL, NULL);
+ if (tofree == NULL) {
+ emsg_funcname(e_unknown_function_str, func);
+ return;
+ }
+ func = tofree;
dict_T *selfdict = NULL;
if (argvars[2].v_type != VAR_UNKNOWN) {
if (tv_check_for_dict_arg(argvars, 2) == FAIL) {
- if (owned) {
- func_unref(func);
- }
- return;
+ goto done;
}
selfdict = argvars[2].vval.v_dict;
}
func_call(func, &argvars[1], partial, selfdict, rettv);
+
+done:
if (owned) {
func_unref(func);
}
+ xfree(tofree);
}
/// "changenr()" function
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 4f1098632c..a24a3d5622 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -78,7 +78,6 @@ static funccall_T *current_funccal = NULL;
// item in it is still being used.
static funccall_T *previous_funccal = NULL;
-static const char *e_unknown_function_str = N_("E117: Unknown function: %s");
static const char *e_funcexts = N_("E122: Function %s already exists, add ! to replace it");
static const char *e_funcdict = N_("E717: Dictionary entry already exists");
static const char *e_funcref = N_("E718: Funcref required");
diff --git a/test/functional/vimscript/ctx_functions_spec.lua b/test/functional/vimscript/ctx_functions_spec.lua
index 873e4f820d..85a74c0ab6 100644
--- a/test/functional/vimscript/ctx_functions_spec.lua
+++ b/test/functional/vimscript/ctx_functions_spec.lua
@@ -188,7 +188,10 @@ describe('context functions', function()
function RestoreFuncs()
call ctxpop()
endfunction
+
+ let g:sid = expand('<SID>')
]])
+ local sid = api.nvim_get_var('sid')
eq('Hello, World!', exec_capture([[call Greet('World')]]))
eq(
@@ -200,11 +203,11 @@ describe('context functions', function()
call('DeleteSFuncs')
eq(
- 'function Greet, line 1: Vim(call):E117: Unknown function: s:greet',
+ ('function Greet, line 1: Vim(call):E117: Unknown function: %sgreet'):format(sid),
pcall_err(command, [[call Greet('World')]])
)
eq(
- 'function GreetAll, line 1: Vim(call):E117: Unknown function: s:greet_all',
+ ('function GreetAll, line 1: Vim(call):E117: Unknown function: %sgreet_all'):format(sid),
pcall_err(command, [[call GreetAll('World', 'One', 'Two', 'Three')]])
)
diff --git a/test/old/testdir/test_user_func.vim b/test/old/testdir/test_user_func.vim
index 3c24412eb7..b509b03778 100644
--- a/test/old/testdir/test_user_func.vim
+++ b/test/old/testdir/test_user_func.vim
@@ -380,7 +380,7 @@ func Test_script_local_func()
" Try to call a script local function in global scope
let lines =<< trim [CODE]
:call assert_fails('call s:Xfunc()', 'E81:')
- :call assert_fails('let x = call("<SID>Xfunc", [])', 'E120:')
+ :call assert_fails('let x = call("<SID>Xfunc", [])', ['E81:', 'E117:'])
:call writefile(v:errors, 'Xresult')
:qall