diff src/ex_docmd.c @ 27716:4097434c7c67 v8.2.4384

patch 8.2.4384: Vim9: error message not tested, some code not tested Commit: https://github.com/vim/vim/commit/bc510064027da8024d59460c9c816aea4ffac096 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Feb 14 21:19:04 2022 +0000 patch 8.2.4384: Vim9: error message not tested, some code not tested Problem: Vim9: error message not tested, some code not tested. Solution: Add a couple of test cases. Give an error for a command modifier without a command.
author Bram Moolenaar <Bram@vim.org>
date Mon, 14 Feb 2022 22:30:03 +0100
parents 1712b102d642
children 2631b9021808
line wrap: on
line diff
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2784,6 +2784,7 @@ parse_command_modifiers(
 {
     char_u  *p;
     int	    starts_with_colon = FALSE;
+    int	    vim9script = in_vim9script();
 
     CLEAR_POINTER(cmod);
     cmod->cmod_flags = sticky_cmdmod_flags;
@@ -2819,12 +2820,18 @@ parse_command_modifiers(
 		if (eap->nextcmd != NULL)
 		    ++eap->nextcmd;
 	    }
+	    if (vim9script && has_cmdmod(cmod, FALSE))
+		*errormsg = _(e_command_modifier_without_command);
 	    return FAIL;
 	}
 	if (*eap->cmd == NUL)
 	{
 	    if (!skip_only)
+	    {
 		ex_pressedreturn = TRUE;
+		if (vim9script && has_cmdmod(cmod, FALSE))
+		    *errormsg = _(e_command_modifier_without_command);
+	    }
 	    return FAIL;
 	}
 
@@ -2838,7 +2845,7 @@ parse_command_modifiers(
 	//   verbose[expr] = 2
 	// But not:
 	//   verbose [a, b] = list
-	if (in_vim9script())
+	if (vim9script)
 	{
 	    char_u *s, *n;
 
@@ -2915,7 +2922,7 @@ parse_command_modifiers(
 #ifdef FEAT_EVAL
 					// in ":filter #pat# cmd" # does not
 					// start a comment
-				     && (!in_vim9script() || VIM_ISWHITE(p[1]))
+				     && (!vim9script || VIM_ISWHITE(p[1]))
 #endif
 				     ))
 				break;
@@ -2928,7 +2935,7 @@ parse_command_modifiers(
 			    }
 #ifdef FEAT_EVAL
 			    // Avoid that "filter(arg)" is recognized.
-			    if (in_vim9script() && !VIM_ISWHITE(p[-1]))
+			    if (vim9script && !VIM_ISWHITE(p[-1]))
 				break;
 #endif
 			    if (skip_only)