mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:7.4.265
Problem: Can't call a global function with "g:" in an expression. Solution: Skip the "g:" when looking up the function. https://code.google.com/p/vim/source/detail?r=8ec9d2196bee0c5108f2d2c196a660a7f4e5f29f
This commit is contained in:
parent
f5a3df7b87
commit
d4f8a86700
20
src/eval.c
20
src/eval.c
@ -7317,28 +7317,34 @@ call_func (
|
|||||||
|
|
||||||
/* execute the function if no errors detected and executing */
|
/* execute the function if no errors detected and executing */
|
||||||
if (evaluate && error == ERROR_NONE) {
|
if (evaluate && error == ERROR_NONE) {
|
||||||
|
char_u *rfname = fname;
|
||||||
|
|
||||||
|
/* Ignore "g:" before a function name. */
|
||||||
|
if (fname[0] == 'g' && fname[1] == ':') {
|
||||||
|
rfname = fname + 2;
|
||||||
|
}
|
||||||
|
|
||||||
rettv->v_type = VAR_NUMBER; /* default rettv is number zero */
|
rettv->v_type = VAR_NUMBER; /* default rettv is number zero */
|
||||||
rettv->vval.v_number = 0;
|
rettv->vval.v_number = 0;
|
||||||
error = ERROR_UNKNOWN;
|
error = ERROR_UNKNOWN;
|
||||||
|
|
||||||
if (!builtin_function(fname, -1)) {
|
if (!builtin_function(rfname, -1)) {
|
||||||
/*
|
/*
|
||||||
* User defined function.
|
* User defined function.
|
||||||
*/
|
*/
|
||||||
fp = find_func(fname);
|
fp = find_func(rfname);
|
||||||
|
|
||||||
/* Trigger FuncUndefined event, may load the function. */
|
/* Trigger FuncUndefined event, may load the function. */
|
||||||
if (fp == NULL
|
if (fp == NULL
|
||||||
&& apply_autocmds(EVENT_FUNCUNDEFINED,
|
&& apply_autocmds(EVENT_FUNCUNDEFINED, rfname, rfname, TRUE, NULL)
|
||||||
fname, fname, TRUE, NULL)
|
|
||||||
&& !aborting()) {
|
&& !aborting()) {
|
||||||
/* executed an autocommand, search for the function again */
|
/* executed an autocommand, search for the function again */
|
||||||
fp = find_func(fname);
|
fp = find_func(rfname);
|
||||||
}
|
}
|
||||||
/* Try loading a package. */
|
/* Try loading a package. */
|
||||||
if (fp == NULL && script_autoload(fname, TRUE) && !aborting()) {
|
if (fp == NULL && script_autoload(rfname, TRUE) && !aborting()) {
|
||||||
/* loaded a package, search for the function again */
|
/* loaded a package, search for the function again */
|
||||||
fp = find_func(fname);
|
fp = find_func(rfname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
|
@ -24,18 +24,20 @@ STARTTEST
|
|||||||
: let @c = v:exception
|
: let @c = v:exception
|
||||||
:endtry
|
:endtry
|
||||||
:" function name starting with/without "g:", buffer-local funcref.
|
:" function name starting with/without "g:", buffer-local funcref.
|
||||||
:function! g:Foo()
|
:function! g:Foo(n)
|
||||||
: let @d = 'called Foo()'
|
: let @d = 'called Foo(' . a:n . ')'
|
||||||
:endfunction
|
:endfunction
|
||||||
:let b:my_func = function('Foo')
|
:let b:my_func = function('Foo')
|
||||||
:let @d = 'xxx'
|
|
||||||
:call b:my_func()
|
|
||||||
:endfunction
|
|
||||||
:" clean up
|
:" clean up
|
||||||
:%d
|
:%d
|
||||||
:pu a
|
:pu a
|
||||||
:pu b
|
:pu b
|
||||||
:pu c
|
:pu c
|
||||||
|
:call b:my_func(1)
|
||||||
|
:pu d
|
||||||
|
:echo g:Foo(2)
|
||||||
|
:pu d
|
||||||
|
:echo Foo(3)
|
||||||
:pu d
|
:pu d
|
||||||
:1d
|
:1d
|
||||||
:wq! test.out
|
:wq! test.out
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
Vim(function):E128: Function name must start with a capital or "s:": g:test()
|
Vim(function):E128: Function name must start with a capital or "s:": g:test()
|
||||||
Vim(function):E128: Function name must start with a capital or "s:": test2() "#
|
Vim(function):E128: Function name must start with a capital or "s:": test2() "#
|
||||||
Vim(function):E128: Function name must start with a capital or "s:": b:test()
|
Vim(function):E128: Function name must start with a capital or "s:": b:test()
|
||||||
called Foo()
|
called Foo(1)
|
||||||
|
called Foo(2)
|
||||||
|
called Foo(3)
|
||||||
|
@ -202,7 +202,7 @@ 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
|
||||||
//265,
|
265,
|
||||||
264,
|
264,
|
||||||
//263,
|
//263,
|
||||||
//262,
|
//262,
|
||||||
|
Loading…
Reference in New Issue
Block a user