mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.4176: Vim9: cannot use imported function with call()
Problem: Vim9: cannot use imported function with call(). Solution: Translate the function name. (closes #9590)
This commit is contained in:
@@ -2929,6 +2929,8 @@ f_call(typval_T *argvars, typval_T *rettv)
|
|||||||
char_u *func;
|
char_u *func;
|
||||||
partial_T *partial = NULL;
|
partial_T *partial = NULL;
|
||||||
dict_T *selfdict = NULL;
|
dict_T *selfdict = NULL;
|
||||||
|
char_u *dot;
|
||||||
|
char_u *tofree = NULL;
|
||||||
|
|
||||||
if (in_vim9script()
|
if (in_vim9script()
|
||||||
&& (check_for_string_or_func_arg(argvars, 0) == FAIL
|
&& (check_for_string_or_func_arg(argvars, 0) == FAIL
|
||||||
@@ -2956,6 +2958,26 @@ f_call(typval_T *argvars, typval_T *rettv)
|
|||||||
if (func == NULL || *func == NUL)
|
if (func == NULL || *func == NUL)
|
||||||
return; // type error, empty name or null function
|
return; // type error, empty name or null function
|
||||||
|
|
||||||
|
dot = vim_strchr(func, '.');
|
||||||
|
if (dot != NULL)
|
||||||
|
{
|
||||||
|
imported_T *import = find_imported(func, dot - func, TRUE, NULL);
|
||||||
|
|
||||||
|
if (import != NULL && SCRIPT_ID_VALID(import->imp_sid))
|
||||||
|
{
|
||||||
|
scriptitem_T *si = SCRIPT_ITEM(import->imp_sid);
|
||||||
|
|
||||||
|
if (si->sn_autoload_prefix != NULL)
|
||||||
|
{
|
||||||
|
// Turn "import.Func" into "scriptname#Func".
|
||||||
|
tofree = concat_str(si->sn_autoload_prefix, dot + 1);
|
||||||
|
if (tofree == NULL)
|
||||||
|
return;
|
||||||
|
func = tofree;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (argvars[2].v_type != VAR_UNKNOWN)
|
if (argvars[2].v_type != VAR_UNKNOWN)
|
||||||
{
|
{
|
||||||
if (argvars[2].v_type != VAR_DICT)
|
if (argvars[2].v_type != VAR_DICT)
|
||||||
@@ -2967,6 +2989,8 @@ f_call(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
(void)func_call(func, &argvars[1], partial, selfdict, rettv);
|
(void)func_call(func, &argvars[1], partial, selfdict, rettv);
|
||||||
|
|
||||||
|
vim_free(tofree);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -706,7 +706,7 @@ def Test_use_autoload_import_in_fold_expression()
|
|||||||
edit! otherfile
|
edit! otherfile
|
||||||
redraw
|
redraw
|
||||||
|
|
||||||
set foldexpr= foldmethod&
|
set foldexpr= foldmethod& debug=
|
||||||
bwipe!
|
bwipe!
|
||||||
delete('Xdir', 'rf')
|
delete('Xdir', 'rf')
|
||||||
&rtp = save_rtp
|
&rtp = save_rtp
|
||||||
@@ -1525,6 +1525,8 @@ def Test_vim9script_autoload_call()
|
|||||||
|
|
||||||
call another.Getother()
|
call another.Getother()
|
||||||
assert_equal('other', g:result)
|
assert_equal('other', g:result)
|
||||||
|
|
||||||
|
assert_equal('arg', call('another.RetArg', ['arg']))
|
||||||
END
|
END
|
||||||
CheckScriptSuccess(lines)
|
CheckScriptSuccess(lines)
|
||||||
|
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4176,
|
||||||
/**/
|
/**/
|
||||||
4175,
|
4175,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user