mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.1.0182: Can define function with invalid name inside 'formatexpr' (#27883)
Problem: Can define function with invalid name inside 'formatexpr'.
Solution: Use goto instead of checking for did_emsg later.
(zeertzjq)
closes: vim/vim#14209
6a04bf5ee5
This commit is contained in:
parent
c0daea3afd
commit
ee89ba1d75
@ -2309,6 +2309,7 @@ void ex_function(exarg_T *eap)
|
|||||||
: eval_isnamec(name_base[i])); i++) {}
|
: eval_isnamec(name_base[i])); i++) {}
|
||||||
if (name_base[i] != NUL) {
|
if (name_base[i] != NUL) {
|
||||||
emsg_funcname(e_invarg2, arg);
|
emsg_funcname(e_invarg2, arg);
|
||||||
|
goto ret_free;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Disallow using the g: dict.
|
// Disallow using the g: dict.
|
||||||
|
@ -891,4 +891,23 @@ func Test_multidefer_with_exception()
|
|||||||
delfunc Foo
|
delfunc Foo
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_func_curly_brace_invalid_name()
|
||||||
|
func Fail()
|
||||||
|
func Foo{'()'}bar()
|
||||||
|
endfunc
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
call assert_fails('call Fail()', 'E475: Invalid argument: Foo()bar')
|
||||||
|
|
||||||
|
silent! call Fail()
|
||||||
|
call assert_equal([], getcompletion('Foo', 'function'))
|
||||||
|
|
||||||
|
set formatexpr=Fail()
|
||||||
|
normal! gqq
|
||||||
|
call assert_equal([], getcompletion('Foo', 'function'))
|
||||||
|
|
||||||
|
set formatexpr&
|
||||||
|
delfunc Fail
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Loading…
Reference in New Issue
Block a user