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 '('.
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 511e8c5..70c0da2 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3146,8 +3146,9 @@
* 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 @@
// "varname[]" is an expression.
// "g:varname" is an expression.
// "varname->expr" is an expression.
+ // "(..." is an expression.
if (*p == '('
|| *p == '['
|| p[1] == ':'