patch 9.1.0182: Can define function with invalid name inside 'formatexpr' Commit: https://github.com/vim/vim/commit/6a04bf5ee523b2d6d01d7290e356a30de219f465 Author: zeertzjq <zeert...@outlook.com> Date: Sat Mar 16 09:39:06 2024 +0100
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 <zeert...@outlook.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/testdir/test_user_func.vim b/src/testdir/test_user_func.vim index 57a093c9c..992329bc7 100644 --- a/src/testdir/test_user_func.vim +++ b/src/testdir/test_user_func.vim @@ -968,4 +968,23 @@ func Test_multidefer_with_exception() delfunc Foo 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 diff --git a/src/userfunc.c b/src/userfunc.c index 00e499fd0..ce144a397 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -4977,7 +4977,10 @@ define_function( : eval_isnamec(name_base[i])); ++i) ; if (name_base[i] != NUL) + { emsg_funcname(e_invalid_argument_str, arg); + goto ret_free; + } // In Vim9 script a function cannot have the same name as a // variable. diff --git a/src/version.c b/src/version.c index 36c120577..9f7819632 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 182, /**/ 181, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/E1rlPf6-004qne-9d%40256bit.org.