diff src/ex_docmd.c @ 19481:c27837cbe922 v8.2.0298

patch 8.2.0298: Vim9 script: cannot start command with a string constant Commit: https://github.com/vim/vim/commit/0c6ceaf90389b41545d803458c4813013811c756 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 22 18:36:32 2020 +0100 patch 8.2.0298: Vim9 script: cannot start command with a string constant Problem: Vim9 script: cannot start command with a string constant. Solution: Recognize expression starting with '('.
author Bram Moolenaar <Bram@vim.org>
date Sat, 22 Feb 2020 18:45:04 +0100
parents 5512aa74cb62
children 639b1d672757
line wrap: on
line diff
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3146,8 +3146,9 @@ find_ex_command(
      * Recognize a Vim9 script function/method call and assignment:
      * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()"
      */
-    if (lookup != NULL && (p = to_name_const_end(eap->cmd)) > eap->cmd
-								  && *p != NUL)
+    p = eap->cmd;
+    if (lookup != NULL && (*p == '('
+	       || ((p = to_name_const_end(eap->cmd)) > eap->cmd && *p != NUL)))
     {
 	int oplen;
 	int heredoc;
@@ -3156,6 +3157,7 @@ find_ex_command(
 	// "varname[]" is an expression.
 	// "g:varname" is an expression.
 	// "varname->expr" is an expression.
+	// "(..." is an expression.
 	if (*p == '('
 		|| *p == '['
 		|| p[1] == ':'