Mercurial > vim
comparison src/ex_docmd.c @ 21122:839ace6773aa v8.2.1112
patch 8.2.1112: Vim9: no line continuation allowed in method call
Commit: https://github.com/vim/vim/commit/5f195938d4d489aa288bdb54ee6112a34aed1df9
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jul 1 20:07:14 2020 +0200
patch 8.2.1112: Vim9: no line continuation allowed in method call
Problem: Vim9: no line continuation allowed in method call.
Solution: Handle line continuation in expression before method call.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 01 Jul 2020 20:15:03 +0200 |
parents | a7c202f5cbe9 |
children | 4a1e8086759b |
comparison
equal
deleted
inserted
replaced
21121:59e2379e7479 | 21122:839ace6773aa |
---|---|
3217 /* | 3217 /* |
3218 * Recognize a Vim9 script function/method call and assignment: | 3218 * Recognize a Vim9 script function/method call and assignment: |
3219 * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()" | 3219 * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()" |
3220 */ | 3220 */ |
3221 p = eap->cmd; | 3221 p = eap->cmd; |
3222 if (lookup != NULL && (*p == '(' | 3222 if (lookup != NULL && (*p == '(' || *p == '[' || *p == '{' |
3223 || ((p = to_name_const_end(eap->cmd)) > eap->cmd && *p != NUL))) | 3223 || ((p = to_name_const_end(eap->cmd)) > eap->cmd && *p != NUL))) |
3224 { | 3224 { |
3225 int oplen; | 3225 int oplen; |
3226 int heredoc; | 3226 int heredoc; |
3227 | 3227 |
3228 // "funcname(" is always a function call. | 3228 // "funcname(" is always a function call. |
3229 // "varname[]" is an expression. | 3229 // "varname[]" is an expression. |
3230 // "g:varname" is an expression. | 3230 // "g:varname" is an expression. |
3231 // "varname->expr" is an expression. | 3231 // "varname->expr" is an expression. |
3232 // "(..." is an expression. | 3232 // "(..." is an expression. |
3233 // "{..." is an dict expression. | |
3233 if (*p == '(' | 3234 if (*p == '(' |
3234 || *p == '[' | 3235 || *p == '{' |
3235 || p[1] == ':' | 3236 || p[1] == ':' |
3236 || (*p == '-' && p[1] == '>')) | 3237 || (*p == '-' && p[1] == '>')) |
3237 { | 3238 { |
3238 eap->cmdidx = CMD_eval; | 3239 eap->cmdidx = CMD_eval; |
3239 return eap->cmd; | 3240 return eap->cmd; |
3240 } | 3241 } |
3241 | 3242 |
3243 // Recognize an assignment if we recognize the variable name: | |
3244 // "g:var = expr" | |
3245 // "var = expr" where "var" is a local var name. | |
3242 oplen = assignment_len(skipwhite(p), &heredoc); | 3246 oplen = assignment_len(skipwhite(p), &heredoc); |
3243 if (oplen > 0) | 3247 if (oplen > 0) |
3244 { | 3248 { |
3245 // Recognize an assignment if we recognize the variable name: | |
3246 // "g:var = expr" | |
3247 // "var = expr" where "var" is a local var name. | |
3248 if (((p - eap->cmd) > 2 && eap->cmd[1] == ':') | 3249 if (((p - eap->cmd) > 2 && eap->cmd[1] == ':') |
3249 || lookup(eap->cmd, p - eap->cmd, cctx) != NULL) | 3250 || lookup(eap->cmd, p - eap->cmd, cctx) != NULL) |
3250 { | 3251 { |
3251 eap->cmdidx = CMD_let; | 3252 eap->cmdidx = CMD_let; |
3252 return eap->cmd; | 3253 return eap->cmd; |
3253 } | 3254 } |
3255 } | |
3256 | |
3257 // "[...]->Method()" is a list expression. But "[a, b] = Func()" is | |
3258 // an assignment. | |
3259 if (*p == '[' && (eval_list(&p, NULL, NULL, FALSE) == FAIL | |
3260 || *skipwhite(p) != '=')) | |
3261 { | |
3262 eap->cmdidx = CMD_eval; | |
3263 return eap->cmd; | |
3254 } | 3264 } |
3255 } | 3265 } |
3256 #endif | 3266 #endif |
3257 | 3267 |
3258 /* | 3268 /* |