summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2014-04-23 20:43:41 +0200
committerBram Moolenaar <Bram@vim.org>2014-04-23 20:43:41 +0200
commiteccb7fc3158877d93194e6b7c0f7e542b4544137 (patch)
treec4fbd5ab6d78bd46b25d796a2b9451c1e0b63f31
parent163d0da508d1a206e6a6ee7e2a34fa0a583ae16c (diff)
updated for version 7.4.264v7.4.264
Problem: Can't define a function starting with "g:". Can't assign a funcref to a buffer-local variable. Solution: Skip "g:" at the start of a function name. Don't check for colons when assigning to a variable.
-rw-r--r--src/eval.c13
-rw-r--r--src/testdir/test_eval.in18
-rw-r--r--src/testdir/test_eval.okbin10736 -> 10827 bytes
-rw-r--r--src/version.c2
4 files changed, 26 insertions, 7 deletions
diff --git a/src/eval.c b/src/eval.c
index c96a4e4e50..d0b58ea635 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -21583,7 +21583,6 @@ ex_function(eap)
* Get the function name. There are these situations:
* func normal function name
* "name" == func, "fudi.fd_dict" == NULL
- * s:func script-local function name
* dict.func new dictionary entry
* "name" == NULL, "fudi.fd_dict" set,
* "fudi.fd_di" == NULL, "fudi.fd_newkey" == func
@@ -21593,6 +21592,8 @@ ex_function(eap)
* dict.func existing dict entry that's not a Funcref
* "name" == NULL, "fudi.fd_dict" set,
* "fudi.fd_di" set, "fudi.fd_newkey" == NULL
+ * s:func script-local function name
+ * g:func global function name, same as "func"
*/
p = eap->arg;
name = trans_function_name(&p, eap->skip, 0, &fudi);
@@ -22286,7 +22287,8 @@ trans_function_name(pp, skip, flags, fdp)
}
else
{
- if (lead == 2) /* skip over "s:" */
+ /* skip over "s:" and "g:" */
+ if (lead == 2 || (lv.ll_name[0] == 'g' && lv.ll_name[1] == ':'))
lv.ll_name += 2;
len = (int)(end - lv.ll_name);
}
@@ -22317,17 +22319,16 @@ trans_function_name(pp, skip, flags, fdp)
else if (!(flags & TFN_INT) && builtin_function(lv.ll_name, len))
{
EMSG2(_("E128: Function name must start with a capital or \"s:\": %s"),
- lv.ll_name);
+ start);
goto theend;
}
- if (!skip)
+ if (!skip && !(flags & TFN_QUIET))
{
char_u *cp = vim_strchr(lv.ll_name, ':');
if (cp != NULL && cp < end)
{
- EMSG2(_("E884: Function name cannot contain a colon: %s"),
- lv.ll_name);
+ EMSG2(_("E884: Function name cannot contain a colon: %s"), start);
goto theend;
}
}
diff --git a/src/testdir/test_eval.in b/src/testdir/test_eval.in
index cb942011be..4919694bea 100644
--- a/src/testdir/test_eval.in
+++ b/src/testdir/test_eval.in
@@ -144,7 +144,7 @@ endfun
:delcommand AR
:call garbagecollect(1)
:"
-:" function name includes a colon
+:" function name not starting with capital
:try
:func! g:test()
:echo "test"
@@ -153,6 +153,15 @@ endfun
:$put =v:exception
:endtry
:"
+:" function name includes a colon
+:try
+:func! b:test()
+:echo "test"
+:endfunc
+:catch
+:$put =v:exception
+:endtry
+:"
:" function name folowed by #
:try
:func! test2() "#
@@ -162,6 +171,13 @@ endfun
:$put =v:exception
:endtry
:"
+:" function name starting with/without "g:", buffer-local funcref.
+:function! g:Foo()
+: $put ='called Foo()'
+:endfunction
+:let b:my_func = function('Foo')
+:call b:my_func()
+:"
:/^start:/+1,$wq! test.out
:" vim: et ts=4 isk-=\: fmr=???,???
:call getchar()
diff --git a/src/testdir/test_eval.ok b/src/testdir/test_eval.ok
index a0d0e458ce..57383be748 100644
--- a/src/testdir/test_eval.ok
+++ b/src/testdir/test_eval.ok
Binary files differ
diff --git a/src/version.c b/src/version.c
index 0ab6fa6088..fc95a5ad02 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 */
/**/
+ 264,
+/**/
263,
/**/
262,