diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-07-04 22:48:12 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-07-04 22:48:12 +0200 |
commit | 6977dba04b68b91410585ada65079651788ca7dc (patch) | |
tree | 824eed5db2f464f49d779a681d082ea37904322d | |
parent | 97f227d9c9351f12138d923ffdf9232dc5520bef (diff) | |
download | vim-git-6977dba04b68b91410585ada65079651788ca7dc.tar.gz |
patch 8.2.3106: Vim9: confusing line number reported for errorv8.2.3106
Problem: Vim9: confusing line number reported for error.
Solution: Use the start line number for the store instruction.
(closes #8488)
-rw-r--r-- | src/testdir/test_vim9_assign.vim | 10 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 14 |
3 files changed, 25 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim index 72884e5ed..a92a60bbd 100644 --- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -388,6 +388,16 @@ def Test_assign_linebreak() ->copy() END CheckDefFailure(lines, 'E1012:', 2) + + lines =<< trim END + var x: any + x.key = 1 + + 2 + + 3 + + 4 + + 5 + END + CheckDefExecAndScriptFailure2(lines, 'E1148:', 'E1203:', 2) enddef def Test_assign_index() diff --git a/src/version.c b/src/version.c index 1f3747970..10231abd8 100644 --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3106, +/**/ 3105, /**/ 3104, diff --git a/src/vim9compile.c b/src/vim9compile.c index 88086cefd..9569f2f4d 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -6726,7 +6726,8 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx) var_start = arg; for (var_idx = 0; var_idx == 0 || var_idx < var_count; var_idx++) { - int instr_count = -1; + int instr_count = -1; + int save_lnum; if (var_start[0] == '_' && !eval_isnamec(var_start[1])) { @@ -6979,13 +6980,20 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx) goto theend; } + // Use the line number of the assignment for store instruction. + save_lnum = cctx->ctx_lnum; + cctx->ctx_lnum = start_lnum - 1; + if (lhs.lhs_has_index) { // Use the info in "lhs" to store the value at the index in the // list or dict. if (compile_assign_unlet(var_start, &lhs, TRUE, rhs_type, cctx) == FAIL) + { + cctx->ctx_lnum = save_lnum; goto theend; + } } else { @@ -7006,8 +7014,12 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx) generate_SETTYPE(cctx, lhs.lhs_type); if (generate_store_lhs(cctx, &lhs, instr_count) == FAIL) + { + cctx->ctx_lnum = save_lnum; goto theend; + } } + cctx->ctx_lnum = save_lnum; if (var_idx + 1 < var_count) var_start = skipwhite(lhs.lhs_dest_end + 1); |