Skip to content

Commit 5582ef1

Browse files
committed
patch 8.0.0004
Problem: A string argument for function() that is not a function name results in an error message with NULL. (Christian Brabandt) Solution: Use the argument for the error message.
1 parent 789a5c0 commit 5582ef1

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/evalfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3612,7 +3612,7 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref)
36123612

36133613
if (s == NULL || *s == NUL || (use_string && VIM_ISDIGIT(*s))
36143614
|| (is_funcref && trans_name == NULL))
3615-
EMSG2(_(e_invarg2), s);
3615+
EMSG2(_(e_invarg2), use_string ? get_tv_string(&argvars[0]) : s);
36163616
/* Don't check an autoload name for existence here. */
36173617
else if (trans_name != NULL && (is_funcref
36183618
? find_func(trans_name) == NULL

src/testdir/test_expr.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,9 @@ func Test_function_with_funcref()
439439
let s:fref = function(s:f)
440440
call assert_equal(v:t_string, s:fref('x'))
441441
call assert_fails("call function('s:f')", 'E700:')
442+
443+
call assert_fails("call function('foo()')", 'E475:')
444+
call assert_fails("call function('foo()')", 'foo()')
442445
endfunc
443446

444447
func Test_funcref()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
4,
767769
/**/
768770
3,
769771
/**/

0 commit comments

Comments
 (0)