mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 9.1.0182: Can define function with invalid name inside 'formatexpr'
Problem: Can define function with invalid name inside 'formatexpr'. Solution: Use goto instead of checking for did_emsg later. (zeertzjq) closes: #14209 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
20eaf8b78d
commit
6a04bf5ee5
@@ -968,4 +968,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
|
||||||
|
@@ -4977,7 +4977,10 @@ define_function(
|
|||||||
: 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_invalid_argument_str, arg);
|
emsg_funcname(e_invalid_argument_str, arg);
|
||||||
|
goto ret_free;
|
||||||
|
}
|
||||||
|
|
||||||
// In Vim9 script a function cannot have the same name as a
|
// In Vim9 script a function cannot have the same name as a
|
||||||
// variable.
|
// variable.
|
||||||
|
@@ -704,6 +704,8 @@ 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 */
|
||||||
|
/**/
|
||||||
|
182,
|
||||||
/**/
|
/**/
|
||||||
181,
|
181,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user