Skip to content

Commit 6977dba

Browse files
committed
patch 8.2.3106: Vim9: confusing line number reported for error
Problem: Vim9: confusing line number reported for error. Solution: Use the start line number for the store instruction. (closes #8488)
1 parent 97f227d commit 6977dba

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/testdir/test_vim9_assign.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,16 @@ def Test_assign_linebreak()
388388
->copy()
389389
END
390390
CheckDefFailure(lines, 'E1012:', 2)
391+
392+
lines =<< trim END
393+
var x: any
394+
x.key = 1
395+
+ 2
396+
+ 3
397+
+ 4
398+
+ 5
399+
END
400+
CheckDefExecAndScriptFailure2(lines, 'E1148:', 'E1203:', 2)
391401
enddef
392402

393403
def Test_assign_index()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3106,
758760
/**/
759761
3105,
760762
/**/

src/vim9compile.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6726,7 +6726,8 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
67266726
var_start = arg;
67276727
for (var_idx = 0; var_idx == 0 || var_idx < var_count; var_idx++)
67286728
{
6729-
int instr_count = -1;
6729+
int instr_count = -1;
6730+
int save_lnum;
67306731

67316732
if (var_start[0] == '_' && !eval_isnamec(var_start[1]))
67326733
{
@@ -6979,13 +6980,20 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
69796980
goto theend;
69806981
}
69816982

6983+
// Use the line number of the assignment for store instruction.
6984+
save_lnum = cctx->ctx_lnum;
6985+
cctx->ctx_lnum = start_lnum - 1;
6986+
69826987
if (lhs.lhs_has_index)
69836988
{
69846989
// Use the info in "lhs" to store the value at the index in the
69856990
// list or dict.
69866991
if (compile_assign_unlet(var_start, &lhs, TRUE, rhs_type, cctx)
69876992
== FAIL)
6993+
{
6994+
cctx->ctx_lnum = save_lnum;
69886995
goto theend;
6996+
}
69896997
}
69906998
else
69916999
{
@@ -7006,8 +7014,12 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
70067014
generate_SETTYPE(cctx, lhs.lhs_type);
70077015

70087016
if (generate_store_lhs(cctx, &lhs, instr_count) == FAIL)
7017+
{
7018+
cctx->ctx_lnum = save_lnum;
70097019
goto theend;
7020+
}
70107021
}
7022+
cctx->ctx_lnum = save_lnum;
70117023

70127024
if (var_idx + 1 < var_count)
70137025
var_start = skipwhite(lhs.lhs_dest_end + 1);

0 commit comments

Comments
 (0)