mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.1152: Vim9: function reference is missing script prefix
Problem: Vim9: function reference is missing script prefix. Solution: Use the actual function name instead of the name searched for in the script context. (closes #6412)
This commit is contained in:
@@ -980,6 +980,39 @@ def Test_vim9script_reload_import()
|
|||||||
delete('Ximport.vim')
|
delete('Ximport.vim')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
" Not exported function that is referenced needs to be accessed by the
|
||||||
|
" script-local name.
|
||||||
|
def Test_vim9script_funcref()
|
||||||
|
let sortlines =<< trim END
|
||||||
|
vim9script
|
||||||
|
def Compare(i1: number, i2: number): number
|
||||||
|
return 1
|
||||||
|
enddef
|
||||||
|
|
||||||
|
export def FastSort(): list<number>
|
||||||
|
return range(5)->sort(Compare)
|
||||||
|
enddef
|
||||||
|
END
|
||||||
|
writefile(sortlines, 'Xsort.vim')
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
import FastSort from './Xsort.vim'
|
||||||
|
def Test()
|
||||||
|
g:result = FastSort()
|
||||||
|
enddef
|
||||||
|
Test()
|
||||||
|
END
|
||||||
|
writefile(lines, 'Xscript.vim')
|
||||||
|
|
||||||
|
source Xscript.vim
|
||||||
|
assert_equal([4, 3, 2, 1, 0], g:result)
|
||||||
|
|
||||||
|
unlet g:result
|
||||||
|
delete('Xsort.vim')
|
||||||
|
delete('Xscript.vim')
|
||||||
|
enddef
|
||||||
|
|
||||||
def Test_vim9script_reload_delfunc()
|
def Test_vim9script_reload_delfunc()
|
||||||
let first_lines =<< trim END
|
let first_lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
1152,
|
||||||
/**/
|
/**/
|
||||||
1151,
|
1151,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -2676,7 +2676,8 @@ generate_funcref(cctx_T *cctx, char_u *name)
|
|||||||
if (ufunc == NULL)
|
if (ufunc == NULL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
return generate_PUSHFUNC(cctx, vim_strsave(name), ufunc->uf_func_type);
|
return generate_PUSHFUNC(cctx, vim_strsave(ufunc->uf_name),
|
||||||
|
ufunc->uf_func_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user