diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-07-02 21:11:34 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-07-02 21:11:34 +0200 |
commit | d2ef6b320bf2e2f3fcc0bb858b16898e6f74b4d9 (patch) | |
tree | 8e3460fe5504df39ed2090799bbf1fe6c9d4df23 /src/ex_docmd.c | |
parent | c19fd917be656b127c5619080f866a23ce1fe755 (diff) |
patch 8.2.1116: Vim9: parsing command checks for list twicev8.2.1116
Problem: Vim9: parsing command checks for list twice.
Solution: Adjust how a command is parsed.
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r-- | src/ex_docmd.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 0c55a57c5c..a5562cc28a 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -3219,8 +3219,9 @@ find_ex_command( * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()" */ p = eap->cmd; - if (lookup != NULL && (*p == '(' || *p == '[' || *p == '{' - || ((p = to_name_const_end(eap->cmd)) > eap->cmd && *p != NUL))) + if (lookup != NULL && (*p == '(' || *p == '{' + || ((p = to_name_const_end(eap->cmd)) > eap->cmd && *p != NUL) + || *p == '[')) { int oplen; int heredoc; @@ -3233,6 +3234,7 @@ find_ex_command( // "{..." is an dict expression. if (*p == '(' || *p == '{' + || (*p == '[' && p > eap->cmd) || p[1] == ':' || (*p == '-' && p[1] == '>')) { @@ -3240,6 +3242,18 @@ find_ex_command( return eap->cmd; } + // "[...]->Method()" is a list expression, but "[a, b] = Func()" is + // an assignment. + // If there is no line break inside the "[...]" then "p" is advanced to + // after the "]" by to_name_const_end(): check if a "=" follows. + // If "[...]" has a line break "p" still points at the "[" and it can't + // be an assignment. + if (*eap->cmd == '[' && (p == eap->cmd || *skipwhite(p) != '=')) + { + eap->cmdidx = CMD_eval; + return eap->cmd; + } + // Recognize an assignment if we recognize the variable name: // "g:var = expr" // "var = expr" where "var" is a local var name. @@ -3253,15 +3267,6 @@ find_ex_command( return eap->cmd; } } - - // "[...]->Method()" is a list expression. But "[a, b] = Func()" is - // an assignment. - if (*p == '[' && (eval_list(&p, NULL, NULL, FALSE) == FAIL - || *skipwhite(p) != '=')) - { - eap->cmdidx = CMD_eval; - return eap->cmd; - } } #endif |