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/ex_docmd.c b/src/ex_docmd.c
index 93f33ae..4755a01 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -1729,7 +1729,14 @@
 
 #ifdef FEAT_EVAL
     if (current_sctx.sc_version == SCRIPT_VERSION_VIM9 && !starts_with_colon)
+    {
+	if (ea.cmd > cmd)
+	{
+	    emsg(_(e_colon_required));
+	    goto doend;
+	}
 	p = find_ex_command(&ea, NULL, lookup_scriptvar, NULL);
+    }
     else
 #endif
 	p = find_ex_command(&ea, NULL, NULL, NULL);
@@ -3446,7 +3453,7 @@
  * Backslashed delimiters after / or ? will be skipped, and commands will
  * not be expanded between /'s and ?'s or after "'".
  *
- * Also skip white space and ":" characters.
+ * Also skip white space and ":" characters after the range.
  * Returns the "cmd" pointer advanced to beyond the range.
  */
     char_u *
diff --git a/src/globals.h b/src/globals.h
index a8ff50c..cd15491 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -1790,6 +1790,7 @@
 EXTERN char e_type_req[]	INIT(= N_("E1022: type or initialization required"));
 EXTERN char e_declare_var[]	INIT(= N_("E1016: Cannot declare a %s variable: %s"));
 EXTERN char e_declare_env_var[]	INIT(= N_("E1016: Cannot declare an environment variable: %s"));
+EXTERN char e_colon_required[]	INIT(= N_("E1050: Colon required before a range"));
 #endif
 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
 EXTERN char e_alloc_color[]	INIT(= N_("E254: Cannot allocate color %s"));
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index b46e04b..46816fd 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -585,12 +585,12 @@
   call CheckDefFailure(["let x = '1' ..'2'"], msg)
   call CheckDefFailure(["let x = '1'.. '2'"], msg)
 
-  call CheckDefFailure(["let x = 0z1122 + 33"], 'E1035')
-  call CheckDefFailure(["let x = 0z1122 + [3]"], 'E1035')
-  call CheckDefFailure(["let x = 0z1122 + 'asd'"], 'E1035')
-  call CheckDefFailure(["let x = 33 + 0z1122"], 'E1035')
-  call CheckDefFailure(["let x = [3] + 0z1122"], 'E1035')
-  call CheckDefFailure(["let x = 'asdf' + 0z1122"], 'E1035')
+  call CheckDefFailure(["let x = 0z1122 + 33"], 'E1051')
+  call CheckDefFailure(["let x = 0z1122 + [3]"], 'E1051')
+  call CheckDefFailure(["let x = 0z1122 + 'asd'"], 'E1051')
+  call CheckDefFailure(["let x = 33 + 0z1122"], 'E1051')
+  call CheckDefFailure(["let x = [3] + 0z1122"], 'E1051')
+  call CheckDefFailure(["let x = 'asdf' + 0z1122"], 'E1051')
   call CheckDefFailure(["let x = 6 + xxx"], 'E1001')
 endfunc
 
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index a733bf1..ff1b134 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -468,6 +468,14 @@
   call CheckDefFailure(['const &option'], 'E996:')
 endfunc
 
+def Test_range_no_colon()
+  call CheckDefFailure(['%s/a/b/'], 'E1050:')
+  call CheckDefFailure(['+ s/a/b/'], 'E1050:')
+  call CheckDefFailure(['- s/a/b/'], 'E1050:')
+  call CheckDefFailure(['. s/a/b/'], 'E1050:')
+enddef
+
+
 def Test_block()
   let outer = 1
   {
@@ -1279,7 +1287,7 @@
   echomsg 'some' 'more' # comment
   assert_match('^some more$', Screenline(&lines))
   echo 'clear'
-  1messages
+  :1messages
   assert_match('^some more$', Screenline(&lines))
 
   call CheckDefFailure(['echomsg "xxx"# comment'], 'E488:')
@@ -1898,7 +1906,7 @@
       'vim9script',
       'new'
       'call setline(1, ["# define pat", "last"])',
-      '$',
+      ':$',
       'dsearch /pat/ #comment',
       'bwipe!',
       ])
@@ -1907,7 +1915,7 @@
       'vim9script',
       'new'
       'call setline(1, ["# define pat", "last"])',
-      '$',
+      ':$',
       'dsearch /pat/#comment',
       'bwipe!',
       ], 'E488:')
diff --git a/src/version.c b/src/version.c
index 4b4fb40..f4afb9a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1042,
+/**/
     1041,
 /**/
     1040,
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);