diff options
author | Bram Moolenaar <Bram@vim.org> | 2014-04-24 17:12:33 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2014-04-24 17:12:33 +0200 |
commit | a4f317df89e662a964197f2d586ac24cf801f14f (patch) | |
tree | 5568e2203b9d9b06536284f7ce1311fef3a22bb9 | |
parent | eccb7fc3158877d93194e6b7c0f7e542b4544137 (diff) | |
download | vim-a4f317df89e662a964197f2d586ac24cf801f14f.zip |
updated for version 7.4.265
Problem: Can't call a global function with "g:" in an expression.
Solution: Skip the "g:" when looking up the function.
-rw-r--r-- | src/eval.c | 18 | ||||
-rw-r--r-- | src/testdir/test_eval.in | 8 | ||||
-rw-r--r-- | src/testdir/test_eval.ok | bin | 10827 -> 10856 bytes | |||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 19 insertions, 9 deletions
diff --git a/src/eval.c b/src/eval.c index d0b58ea63..f91578928 100644 --- a/src/eval.c +++ b/src/eval.c @@ -8485,33 +8485,39 @@ call_func(funcname, len, rettv, argcount, argvars, firstline, lastline, /* execute the function if no errors detected and executing */ 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->vval.v_number = 0; error = ERROR_UNKNOWN; - if (!builtin_function(fname, -1)) + if (!builtin_function(rfname, -1)) { /* * User defined function. */ - fp = find_func(fname); + fp = find_func(rfname); #ifdef FEAT_AUTOCMD /* Trigger FuncUndefined event, may load the function. */ if (fp == NULL && apply_autocmds(EVENT_FUNCUNDEFINED, - fname, fname, TRUE, NULL) + rfname, rfname, TRUE, NULL) && !aborting()) { /* executed an autocommand, search for the function again */ - fp = find_func(fname); + fp = find_func(rfname); } #endif /* 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 */ - fp = find_func(fname); + fp = find_func(rfname); } if (fp != NULL) diff --git a/src/testdir/test_eval.in b/src/testdir/test_eval.in index 4919694be..214a99edb 100644 --- a/src/testdir/test_eval.in +++ b/src/testdir/test_eval.in @@ -172,11 +172,13 @@ endfun :endtry :" :" function name starting with/without "g:", buffer-local funcref. -:function! g:Foo() -: $put ='called Foo()' +:function! g:Foo(n) +: $put ='called Foo(' . a:n . ')' :endfunction :let b:my_func = function('Foo') -:call b:my_func() +:call b:my_func(1) +:echo g:Foo(2) +:echo Foo(3) :" :/^start:/+1,$wq! test.out :" vim: et ts=4 isk-=\: fmr=???,??? diff --git a/src/testdir/test_eval.ok b/src/testdir/test_eval.ok Binary files differindex 57383be74..cfe045b53 100644 --- a/src/testdir/test_eval.ok +++ b/src/testdir/test_eval.ok diff --git a/src/version.c b/src/version.c index fc95a5ad0..94d985705 100644 --- a/src/version.c +++ b/src/version.c @@ -735,6 +735,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 265, +/**/ 264, /**/ 263, |