Mercurial > vim
diff src/userfunc.c @ 21909:a211bca98bc3 v8.2.1504
patch 8.2.1504: Vim9: white space checks are only done for a :def function
Commit: https://github.com/vim/vim/commit/7cb6fc29d067ed97c0b0c1d2d5767125ef9ae1ab
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 21 22:36:47 2020 +0200
patch 8.2.1504: Vim9: white space checks are only done for a :def function
Problem: Vim9: white space checks are only done for a :def function.
Solution: Also do checks at the script level. Adjust the name of a few
error messages.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 21 Aug 2020 22:45:03 +0200 |
parents | a427f5f26419 |
children | ba2415df82d7 |
line wrap: on
line diff
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -119,7 +119,7 @@ one_function_arg(char_u *arg, garray_T * ++p; if (!VIM_ISWHITE(*p)) { - semsg(_(e_white_space_required_after), ":"); + semsg(_(e_white_space_required_after_str), ":"); return arg; } type = skipwhite(p); @@ -276,7 +276,7 @@ get_function_args( if (!skip && in_vim9script() && !IS_WHITE_OR_NUL(*p) && *p != endchar) { - semsg(_(e_white_space_required_after), ","); + semsg(_(e_white_space_required_after_str), ","); goto err_ret; } } @@ -623,6 +623,7 @@ get_func_tv( int ret = OK; typval_T argvars[MAX_FUNC_ARGS + 1]; // vars for arguments int argcount = 0; // number of arguments found + int vim9script = in_vim9script(); /* * Get the arguments. @@ -644,10 +645,25 @@ get_func_tv( ++argcount; // The comma should come right after the argument, but this wasn't // checked previously, thus only enforce it in Vim9 script. - if (!in_vim9script()) + if (vim9script) + { + if (*argp != ',' && *skipwhite(argp) == ',') + { + semsg(_(e_no_white_space_allowed_before_str), ","); + ret = FAIL; + break; + } + } + else argp = skipwhite(argp); if (*argp != ',') break; + if (vim9script && !IS_WHITE_OR_NUL(argp[1])) + { + semsg(_(e_white_space_required_after_str), ","); + ret = FAIL; + break; + } } argp = skipwhite_and_linebreak(argp, evalarg); if (*argp == ')') @@ -3275,7 +3291,7 @@ def_function(exarg_T *eap, char_u *name_ || fp->uf_script_ctx.sc_seq == current_sctx.sc_seq))) { if (vim9script) - emsg_funcname(e_name_already_defined, name); + emsg_funcname(e_name_already_defined_str, name); else emsg_funcname(e_funcexts, name); goto erret;