0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.1042: Vim9: cannot put an operator on the next line

Problem:    Vim9: cannot put an operator on the next line.
Solution:   Require a colon before a range to see if that causes problems.
This commit is contained in:
Bram Moolenaar
2020-06-22 23:02:51 +02:00
parent 7eaafe65ee
commit df069eec3b
7 changed files with 59 additions and 25 deletions

View File

@@ -643,7 +643,7 @@ check_number_or_float(vartype_T type1, vartype_T type2, char_u *op)
|| type2 == VAR_ANY)))
{
if (*op == '+')
emsg(_("E1035: wrong argument type for +"));
emsg(_("E1051: wrong argument type for +"));
else
semsg(_("E1036: %c requires number or float arguments"), *op);
return FAIL;
@@ -6695,6 +6695,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
{
exarg_T ea;
int starts_with_colon = FALSE;
char_u *cmd;
// Bail out on the first error to avoid a flood of errors and report
// the right line number when inside try/catch.
@@ -6853,7 +6854,13 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
/*
* COMMAND after range
*/
cmd = ea.cmd;
ea.cmd = skip_range(ea.cmd, NULL);
if (ea.cmd > cmd && !starts_with_colon)
{
emsg(_(e_colon_required));
goto erret;
}
p = find_ex_command(&ea, NULL, starts_with_colon ? NULL
: (void *(*)(char_u *, size_t, cctx_T *))lookup_local,
&cctx);
@@ -7008,8 +7015,9 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
line = compile_mult_expr(p, ea.cmdidx, &cctx);
break;
// TODO: other commands with an expression argument
default:
// TODO: other commands with an expression argument
// Not recognized, execute with do_cmdline_cmd().
ea.arg = p;
line = compile_exec(line, &ea, &cctx);