Mercurial > vim
diff src/vim9expr.c @ 27191:63f8dbcf6a74 v8.2.4124
patch 8.2.4124: Vim9: method in compiled function may not see script item
Commit: https://github.com/vim/vim/commit/6389baa6691fde4ca56ec6243ed83322543df300
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 17 20:50:40 2022 +0000
patch 8.2.4124: Vim9: method in compiled function may not see script item
Problem: Vim9: method in compiled function may not see script item.
Solution: Make sure not to skip to the next line. (closes https://github.com/vim/vim/issues/9496)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 17 Jan 2022 22:00:03 +0100 |
parents | 6af18c69c59d |
children | facb54d20a50 |
line wrap: on
line diff
--- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -1732,21 +1732,23 @@ compile_subscript( } else { + int fail; + int save_len = cctx->ctx_ufunc->uf_lines.ga_len; + *paren = NUL; - if (compile_expr8(arg, cctx, ppconst) == FAIL - || *skipwhite(*arg) != NUL) + // do not look in the next line + cctx->ctx_ufunc->uf_lines.ga_len = 1; + fail = compile_expr8(arg, cctx, ppconst) == FAIL + || *skipwhite(*arg) != NUL; + *paren = '('; + cctx->ctx_ufunc->uf_lines.ga_len = save_len; + if (fail) { - *paren = '('; semsg(_(e_invalid_expression_str), pstart); return FAIL; } - *paren = '('; } - // Remember the next instruction index, where the instructions - // for arguments are being written. - expr_isn_end = cctx->ctx_instr.ga_len; - // Compile the arguments. if (**arg != '(') { @@ -1756,6 +1758,11 @@ compile_subscript( semsg(_(e_missing_parenthesis_str), *arg); return FAIL; } + + // Remember the next instruction index, where the instructions + // for arguments are being written. + expr_isn_end = cctx->ctx_instr.ga_len; + *arg = skipwhite(*arg + 1); if (compile_arguments(arg, cctx, &argcount, FALSE) == FAIL) return FAIL;