diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-04-12 20:19:16 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-04-12 20:19:16 +0200 |
commit | e6085c53506e38d07334faa1002ee90b1933b128 (patch) | |
tree | c9bb45883c6ac69a7ff2a02606190aa7d42634be /src/vim9compile.c | |
parent | 2196bce56fcd56b0eaece50c079bac99f5bc31af (diff) |
patch 8.2.0561: Vim9: cannot split function call in multiple linesv8.2.0561
Problem: Vim9: cannot split function call in multiple lines.
Solution: Find more arguments in following lines.
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r-- | src/vim9compile.c | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c index 6abf95cc42..201b7b0983 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -2049,6 +2049,27 @@ free_imported(cctx_T *cctx) } /* + * Get the next line of the function from "cctx". + * Returns NULL when at the end. + */ + static char_u * +next_line_from_context(cctx_T *cctx) +{ + char_u *line = NULL; + + do + { + ++cctx->ctx_lnum; + if (cctx->ctx_lnum >= cctx->ctx_ufunc->uf_lines.ga_len) + break; + line = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[cctx->ctx_lnum]; + SOURCING_LNUM = cctx->ctx_ufunc->uf_script_ctx.sc_lnum + + cctx->ctx_lnum + 1; + } while (line == NULL); + return line; +} + +/* * Generate an instruction to load script-local variable "name", without the * leading "s:". * Also finds imported variables. @@ -2284,8 +2305,21 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount) { char_u *p = *arg; - while (*p != NUL && *p != ')') + for (;;) { + if (*p == NUL) + { + p = next_line_from_context(cctx); + if (p == NULL) + break; + p = skipwhite(p); + } + if (*p == ')') + { + *arg = p + 1; + return OK; + } + if (compile_expr1(&p, cctx) == FAIL) return FAIL; ++*argcount; @@ -2298,19 +2332,14 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount) if (*p == ',') { ++p; - if (!VIM_ISWHITE(*p)) + if (*p != NUL && !VIM_ISWHITE(*p)) semsg(_(e_white_after), ","); } p = skipwhite(p); } - p = skipwhite(p); - if (*p != ')') - { - emsg(_(e_missing_close)); - return FAIL; - } - *arg = p + 1; - return OK; + + emsg(_(e_missing_close)); + return FAIL; } /* @@ -2535,27 +2564,6 @@ need_type(type_T *actual, type_T *expected, int offset, cctx_T *cctx) } /* - * Get the next line of the function from "cctx". - * Returns NULL when at the end. - */ - static char_u * -next_line_from_context(cctx_T *cctx) -{ - char_u *line = NULL; - - do - { - ++cctx->ctx_lnum; - if (cctx->ctx_lnum >= cctx->ctx_ufunc->uf_lines.ga_len) - break; - line = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[cctx->ctx_lnum]; - SOURCING_LNUM = cctx->ctx_ufunc->uf_script_ctx.sc_lnum - + cctx->ctx_lnum + 1; - } while (line == NULL); - return line; -} - -/* * parse a list: [expr, expr] * "*arg" points to the '['. */ |