vim-patch:8.2.2726: confusing error message with white space before comma

Problem:    Confusing error message with white space before comma in the
            arguments of a function declaration.
Solution:   Give a specific error message. (closes vim/vim#2235)

86cdb8a4bd

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2022-10-27 08:30:27 +08:00
parent bd122494cc
commit 1f438b2338

View File

@@ -48,6 +48,8 @@ static char *e_funcexts = N_("E122: Function %s already exists, add ! to replace
static char *e_funcdict = N_("E717: Dictionary entry already exists"); static char *e_funcdict = N_("E717: Dictionary entry already exists");
static char *e_funcref = N_("E718: Funcref required"); static char *e_funcref = N_("E718: Funcref required");
static char *e_nofunc = N_("E130: Unknown function: %s"); static char *e_nofunc = N_("E130: Unknown function: %s");
static char e_no_white_space_allowed_before_str_str[]
= N_("E1068: No white space allowed before '%s': %s");
void func_init(void) void func_init(void)
{ {
@@ -149,6 +151,15 @@ static int get_function_args(char **argp, char_u endchar, garray_T *newargs, int
emsg(_("E989: Non-default argument follows default argument")); emsg(_("E989: Non-default argument follows default argument"));
mustend = true; mustend = true;
} }
if (ascii_iswhite(*p) && *skipwhite(p) == ',') {
// Be tolerant when skipping
if (!skip) {
semsg(_(e_no_white_space_allowed_before_str_str), ",", p);
goto err_ret;
}
p = skipwhite(p);
}
if (*p == ',') { if (*p == ',') {
p++; p++;
} else { } else {