mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Problem: Vim9: cannot find function reference for s:Func. Solution: Recognize <SNR> prefix. (closes #6805)
This commit is contained in:
@@ -1652,6 +1652,10 @@ def Test_vim9script_reload_import()
|
|||||||
delete('Ximport.vim')
|
delete('Ximport.vim')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def s:RetSome(): string
|
||||||
|
return 'some'
|
||||||
|
enddef
|
||||||
|
|
||||||
" Not exported function that is referenced needs to be accessed by the
|
" Not exported function that is referenced needs to be accessed by the
|
||||||
" script-local name.
|
" script-local name.
|
||||||
def Test_vim9script_funcref()
|
def Test_vim9script_funcref()
|
||||||
@@ -1683,6 +1687,9 @@ def Test_vim9script_funcref()
|
|||||||
unlet g:result
|
unlet g:result
|
||||||
delete('Xsort.vim')
|
delete('Xsort.vim')
|
||||||
delete('Xscript.vim')
|
delete('Xscript.vim')
|
||||||
|
|
||||||
|
let Funcref = function('s:RetSome')
|
||||||
|
assert_equal('some', Funcref())
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
" Check that when searching for "FilterFunc" it finds the import in the
|
" Check that when searching for "FilterFunc" it finds the import in the
|
||||||
|
@@ -808,11 +808,12 @@ find_func_even_dead(char_u *name, int is_global, cctx_T *cctx)
|
|||||||
|
|
||||||
if (!is_global)
|
if (!is_global)
|
||||||
{
|
{
|
||||||
int vim9script = in_vim9script();
|
|
||||||
char_u *after_script = NULL;
|
char_u *after_script = NULL;
|
||||||
long sid = 0;
|
long sid = 0;
|
||||||
|
int find_script_local = in_vim9script()
|
||||||
|
&& eval_isnamec1(*name) && name[1] != ':';
|
||||||
|
|
||||||
if (vim9script)
|
if (find_script_local)
|
||||||
{
|
{
|
||||||
// Find script-local function before global one.
|
// Find script-local function before global one.
|
||||||
func = find_func_with_sid(name, current_sctx.sc_sid);
|
func = find_func_with_sid(name, current_sctx.sc_sid);
|
||||||
@@ -833,7 +834,7 @@ find_func_even_dead(char_u *name, int is_global, cctx_T *cctx)
|
|||||||
else
|
else
|
||||||
after_script = NULL;
|
after_script = NULL;
|
||||||
}
|
}
|
||||||
if (vim9script || after_script != NULL)
|
if (find_script_local || after_script != NULL)
|
||||||
{
|
{
|
||||||
// Find imported function before global one.
|
// Find imported function before global one.
|
||||||
if (after_script != NULL && sid != current_sctx.sc_sid)
|
if (after_script != NULL && sid != current_sctx.sc_sid)
|
||||||
|
@@ -754,6 +754,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 */
|
||||||
|
/**/
|
||||||
|
1541,
|
||||||
/**/
|
/**/
|
||||||
1540,
|
1540,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -614,6 +614,7 @@ call_partial(typval_T *tv, int argcount_arg, ectx_T *ectx)
|
|||||||
int argcount = argcount_arg;
|
int argcount = argcount_arg;
|
||||||
char_u *name = NULL;
|
char_u *name = NULL;
|
||||||
int called_emsg_before = called_emsg;
|
int called_emsg_before = called_emsg;
|
||||||
|
int res;
|
||||||
|
|
||||||
if (tv->v_type == VAR_PARTIAL)
|
if (tv->v_type == VAR_PARTIAL)
|
||||||
{
|
{
|
||||||
@@ -650,7 +651,23 @@ call_partial(typval_T *tv, int argcount_arg, ectx_T *ectx)
|
|||||||
}
|
}
|
||||||
else if (tv->v_type == VAR_FUNC)
|
else if (tv->v_type == VAR_FUNC)
|
||||||
name = tv->vval.v_string;
|
name = tv->vval.v_string;
|
||||||
if (name == NULL || call_by_name(name, argcount, ectx, NULL) == FAIL)
|
if (name != NULL)
|
||||||
|
{
|
||||||
|
char_u fname_buf[FLEN_FIXED + 1];
|
||||||
|
char_u *tofree = NULL;
|
||||||
|
int error = FCERR_NONE;
|
||||||
|
char_u *fname;
|
||||||
|
|
||||||
|
// May need to translate <SNR>123_ to K_SNR.
|
||||||
|
fname = fname_trans_sid(name, fname_buf, &tofree, &error);
|
||||||
|
if (error != FCERR_NONE)
|
||||||
|
res = FAIL;
|
||||||
|
else
|
||||||
|
res = call_by_name(fname, argcount, ectx, NULL);
|
||||||
|
vim_free(tofree);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name == NULL || res == FAIL)
|
||||||
{
|
{
|
||||||
if (called_emsg == called_emsg_before)
|
if (called_emsg == called_emsg_before)
|
||||||
semsg(_(e_unknownfunc),
|
semsg(_(e_unknownfunc),
|
||||||
|
Reference in New Issue
Block a user