mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
vim-patch:9.1.1017: Vim9: Patch 9.1.1013 causes a few problems
Problem: Vim9: Patch 9.1.1013 causes a few problems
Solution: Translate the function name only when it is a string
(Yegappan Lakshmanan)
fixes: vim/vim#16453
closes: vim/vim#16450
9904cbca41
Cherry-pick call() change from patch 9.0.0345.
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
@@ -548,8 +548,7 @@ static void f_byte2line(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
/// "call(func, arglist [, dict])" function
|
||||
static void f_call(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
if (argvars[1].v_type != VAR_LIST) {
|
||||
emsg(_(e_listreq));
|
||||
if (tv_check_for_list_arg(argvars, 1) == FAIL) {
|
||||
return;
|
||||
}
|
||||
if (argvars[1].vval.v_list == NULL) {
|
||||
@@ -575,13 +574,16 @@ 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;
|
||||
char *tofree = NULL;
|
||||
if (argvars[0].v_type == VAR_STRING) {
|
||||
char *p = func;
|
||||
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;
|
||||
}
|
||||
func = tofree;
|
||||
|
||||
dict_T *selfdict = NULL;
|
||||
if (argvars[2].v_type != VAR_UNKNOWN) {
|
||||
|
@@ -2672,7 +2672,9 @@ endfunc
|
||||
func Test_call()
|
||||
call assert_equal(3, call('len', [123]))
|
||||
call assert_equal(3, 'len'->call([123]))
|
||||
call assert_fails("call call('len', 123)", 'E714:')
|
||||
call assert_equal(4, call({ x -> len(x) }, ['xxxx']))
|
||||
call assert_equal(2, call(function('len'), ['xx']))
|
||||
call assert_fails("call call('len', 123)", 'E1211:')
|
||||
call assert_equal(0, call('', []))
|
||||
call assert_equal(0, call('len', v:_null_list))
|
||||
|
||||
|
Reference in New Issue
Block a user