mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:7.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. https://code.google.com/p/vim/source/detail?r=00acac0af680c2d8c82db5258474b121a5908926
This commit is contained in:
parent
4d0dd14189
commit
9b9c1dee13
16
src/eval.c
16
src/eval.c
@ -17302,7 +17302,6 @@ void ex_function(exarg_T *eap)
|
|||||||
// Get the function name. There are these situations:
|
// Get the function name. There are these situations:
|
||||||
// func function name
|
// func function name
|
||||||
// "name" == func, "fudi.fd_dict" == NULL
|
// "name" == func, "fudi.fd_dict" == NULL
|
||||||
// s:func script-local function name
|
|
||||||
// dict.func new dictionary entry
|
// dict.func new dictionary entry
|
||||||
// "name" == NULL, "fudi.fd_dict" set,
|
// "name" == NULL, "fudi.fd_dict" set,
|
||||||
// "fudi.fd_di" == NULL, "fudi.fd_newkey" == func
|
// "fudi.fd_di" == NULL, "fudi.fd_newkey" == func
|
||||||
@ -17312,6 +17311,8 @@ void ex_function(exarg_T *eap)
|
|||||||
// dict.func existing dict entry that's not a Funcref
|
// dict.func existing dict entry that's not a Funcref
|
||||||
// "name" == NULL, "fudi.fd_dict" set,
|
// "name" == NULL, "fudi.fd_dict" set,
|
||||||
// "fudi.fd_di" set, "fudi.fd_newkey" == NULL
|
// "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;
|
p = eap->arg;
|
||||||
name = trans_function_name(&p, eap->skip, 0, &fudi);
|
name = trans_function_name(&p, eap->skip, 0, &fudi);
|
||||||
paren = (vim_strchr(p, '(') != NULL);
|
paren = (vim_strchr(p, '(') != NULL);
|
||||||
@ -17917,8 +17918,10 @@ trans_function_name (
|
|||||||
lead = 2;
|
lead = 2;
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
lv.ll_name += 2;
|
||||||
|
}
|
||||||
len = (int)(end - lv.ll_name);
|
len = (int)(end - lv.ll_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17942,17 +17945,16 @@ trans_function_name (
|
|||||||
lead += (int)STRLEN(sid_buf);
|
lead += (int)STRLEN(sid_buf);
|
||||||
}
|
}
|
||||||
} else if (!(flags & TFN_INT) && builtin_function(lv.ll_name, len)) {
|
} else if (!(flags & TFN_INT) && builtin_function(lv.ll_name, len)) {
|
||||||
EMSG2(_(
|
EMSG2(_("E128: Function name must start with a capital or \"s:\": %s"),
|
||||||
"E128: Function name must start with a capital or \"s:\": %s"),
|
start);
|
||||||
lv.ll_name);
|
|
||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skip) {
|
if (!skip && !(flags & TFN_QUIET)) {
|
||||||
char_u *cp = vim_strchr(lv.ll_name, ':');
|
char_u *cp = vim_strchr(lv.ll_name, ':');
|
||||||
|
|
||||||
if (cp != NULL && cp < end) {
|
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;
|
goto theend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
STARTTEST
|
STARTTEST
|
||||||
:" function name includes a colon
|
:" function name not starting with a capital
|
||||||
:try
|
:try
|
||||||
: func! g:test()
|
: func! g:test()
|
||||||
: echo "test"
|
: echo "test"
|
||||||
@ -15,9 +15,28 @@ STARTTEST
|
|||||||
:catch
|
:catch
|
||||||
: let @b = v:exception
|
: let @b = v:exception
|
||||||
:endtry
|
:endtry
|
||||||
|
:" function name includes a colon
|
||||||
|
:try
|
||||||
|
: func! b:test()
|
||||||
|
: echo "test"
|
||||||
|
: endfunc
|
||||||
|
:catch
|
||||||
|
: let @c = v:exception
|
||||||
|
:endtry
|
||||||
|
:" function name starting with/without "g:", buffer-local funcref.
|
||||||
|
:function! g:Foo()
|
||||||
|
: let @d = 'called Foo()'
|
||||||
|
:endfunction
|
||||||
|
:let b:my_func = function('Foo')
|
||||||
|
:let @d = 'xxx'
|
||||||
|
:call b:my_func()
|
||||||
|
:endfunction
|
||||||
|
:" clean up
|
||||||
:%d
|
:%d
|
||||||
:pu a
|
:pu a
|
||||||
:pu b
|
:pu b
|
||||||
|
:pu c
|
||||||
|
:pu d
|
||||||
:1d
|
:1d
|
||||||
:wq! test.out
|
:wq! test.out
|
||||||
ENDTEST
|
ENDTEST
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
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()
|
||||||
|
called Foo()
|
||||||
|
@ -203,7 +203,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,
|
||||||
261,
|
261,
|
||||||
|
Loading…
Reference in New Issue
Block a user