1
0
forked from aniani/vim

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.
This commit is contained in:
Bram Moolenaar 2016-09-14 22:16:13 +02:00
parent 789a5c0e3d
commit 5582ef1438
3 changed files with 6 additions and 1 deletions

View File

@ -3612,7 +3612,7 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref)
if (s == NULL || *s == NUL || (use_string && VIM_ISDIGIT(*s)) if (s == NULL || *s == NUL || (use_string && VIM_ISDIGIT(*s))
|| (is_funcref && trans_name == NULL)) || (is_funcref && trans_name == NULL))
EMSG2(_(e_invarg2), s); EMSG2(_(e_invarg2), use_string ? get_tv_string(&argvars[0]) : s);
/* Don't check an autoload name for existence here. */ /* Don't check an autoload name for existence here. */
else if (trans_name != NULL && (is_funcref else if (trans_name != NULL && (is_funcref
? find_func(trans_name) == NULL ? find_func(trans_name) == NULL

View File

@ -439,6 +439,9 @@ func Test_function_with_funcref()
let s:fref = function(s:f) let s:fref = function(s:f)
call assert_equal(v:t_string, s:fref('x')) call assert_equal(v:t_string, s:fref('x'))
call assert_fails("call function('s:f')", 'E700:') call assert_fails("call function('s:f')", 'E700:')
call assert_fails("call function('foo()')", 'E475:')
call assert_fails("call function('foo()')", 'foo()')
endfunc endfunc
func Test_funcref() func Test_funcref()

View File

@ -764,6 +764,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 */
/**/
4,
/**/ /**/
3, 3,
/**/ /**/