mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.1.1863: confusing error when using a builtin function as method
Problem: Confusing error when using a builtin function as method while it does not support that. Solution: Add a specific error message.
This commit is contained in:
@@ -1113,8 +1113,10 @@ call_internal_method(
|
||||
typval_T argv[MAX_FUNC_ARGS + 1];
|
||||
|
||||
fi = find_internal_func(name);
|
||||
if (fi < 0 || global_functions[fi].f_argtype == 0)
|
||||
if (fi < 0)
|
||||
return ERROR_UNKNOWN;
|
||||
if (global_functions[fi].f_argtype == 0)
|
||||
return ERROR_NOTMETHOD;
|
||||
if (argcount + 1 < global_functions[fi].f_min_argc)
|
||||
return ERROR_TOOFEW;
|
||||
if (argcount + 1 > global_functions[fi].f_max_argc)
|
||||
|
@@ -134,3 +134,7 @@ func Test_method_lambda()
|
||||
" todo: lambda accepts more arguments than it consumes
|
||||
" call assert_fails('eval "text"->{x -> x .. " extended"}("more")', 'E99:')
|
||||
endfunc
|
||||
|
||||
func Test_method_not_supported()
|
||||
call assert_fails('eval 123->changenr()', 'E276:')
|
||||
endfunc
|
||||
|
@@ -1678,6 +1678,11 @@ call_func(
|
||||
case ERROR_UNKNOWN:
|
||||
emsg_funcname(N_("E117: Unknown function: %s"), name);
|
||||
break;
|
||||
case ERROR_NOTMETHOD:
|
||||
emsg_funcname(
|
||||
N_("E276: Cannot use function as a method: %s"),
|
||||
name);
|
||||
break;
|
||||
case ERROR_DELETED:
|
||||
emsg_funcname(N_("E933: Function was deleted: %s"), name);
|
||||
break;
|
||||
@@ -1685,15 +1690,18 @@ call_func(
|
||||
emsg_funcname((char *)e_toomanyarg, name);
|
||||
break;
|
||||
case ERROR_TOOFEW:
|
||||
emsg_funcname(N_("E119: Not enough arguments for function: %s"),
|
||||
emsg_funcname(
|
||||
N_("E119: Not enough arguments for function: %s"),
|
||||
name);
|
||||
break;
|
||||
case ERROR_SCRIPT:
|
||||
emsg_funcname(N_("E120: Using <SID> not in a script context: %s"),
|
||||
emsg_funcname(
|
||||
N_("E120: Using <SID> not in a script context: %s"),
|
||||
name);
|
||||
break;
|
||||
case ERROR_DICT:
|
||||
emsg_funcname(N_("E725: Calling dict function without Dictionary: %s"),
|
||||
emsg_funcname(
|
||||
N_("E725: Calling dict function without Dictionary: %s"),
|
||||
name);
|
||||
break;
|
||||
}
|
||||
|
@@ -769,6 +769,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1863,
|
||||
/**/
|
||||
1862,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user