diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-07-01 20:07:14 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-07-01 20:07:14 +0200 |
commit | 5f195938d4d489aa288bdb54ee6112a34aed1df9 (patch) | |
tree | bb8de6af7845c30c1836362f571e55378add4337 /src/ex_docmd.c | |
parent | 9a78e6df17033223ebdf499f2b02b2538601c52d (diff) | |
download | vim-git-5f195938d4d489aa288bdb54ee6112a34aed1df9.tar.gz |
patch 8.2.1112: Vim9: no line continuation allowed in method callv8.2.1112
Problem: Vim9: no line continuation allowed in method call.
Solution: Handle line continuation in expression before method call.
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r-- | src/ex_docmd.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 0ec63e24e..0c55a57c5 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -3219,7 +3219,7 @@ find_ex_command( * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()" */ p = eap->cmd; - if (lookup != NULL && (*p == '(' + if (lookup != NULL && (*p == '(' || *p == '[' || *p == '{' || ((p = to_name_const_end(eap->cmd)) > eap->cmd && *p != NUL))) { int oplen; @@ -3230,8 +3230,9 @@ find_ex_command( // "g:varname" is an expression. // "varname->expr" is an expression. // "(..." is an expression. + // "{..." is an dict expression. if (*p == '(' - || *p == '[' + || *p == '{' || p[1] == ':' || (*p == '-' && p[1] == '>')) { @@ -3239,12 +3240,12 @@ find_ex_command( return eap->cmd; } + // Recognize an assignment if we recognize the variable name: + // "g:var = expr" + // "var = expr" where "var" is a local var name. oplen = assignment_len(skipwhite(p), &heredoc); if (oplen > 0) { - // Recognize an assignment if we recognize the variable name: - // "g:var = expr" - // "var = expr" where "var" is a local var name. if (((p - eap->cmd) > 2 && eap->cmd[1] == ':') || lookup(eap->cmd, p - eap->cmd, cctx) != NULL) { @@ -3252,6 +3253,15 @@ 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 |