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.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 30e447f..39ef5f6 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -643,7 +643,7 @@
|| 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 @@
{
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 @@
/*
* 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 @@
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);