To: vim_dev@googlegroups.com Subject: Patch 8.2.3106 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3106 Problem: Vim9: confusing line number reported for error. Solution: Use the start line number for the store instruction. (closes #8488) Files: src/vim9compile.c, src/testdir/test_vim9_assign.vim *** ../vim-8.2.3105/src/vim9compile.c 2021-07-03 18:56:49.917634884 +0200 --- src/vim9compile.c 2021-07-04 22:46:09.797594248 +0200 *************** *** 6726,6732 **** var_start = arg; for (var_idx = 0; var_idx == 0 || var_idx < var_count; var_idx++) { ! int instr_count = -1; if (var_start[0] == '_' && !eval_isnamec(var_start[1])) { --- 6726,6733 ---- var_start = arg; for (var_idx = 0; var_idx == 0 || var_idx < var_count; var_idx++) { ! int instr_count = -1; ! int save_lnum; if (var_start[0] == '_' && !eval_isnamec(var_start[1])) { *************** *** 6979,6991 **** --- 6980,6999 ---- 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,7013 **** --- 7014,7025 ---- 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); *** ../vim-8.2.3105/src/testdir/test_vim9_assign.vim 2021-07-04 20:20:48.165400896 +0200 --- src/testdir/test_vim9_assign.vim 2021-07-04 22:45:36.905655773 +0200 *************** *** 388,393 **** --- 388,403 ---- ->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() *** ../vim-8.2.3105/src/version.c 2021-07-04 20:20:48.165400896 +0200 --- src/version.c 2021-07-04 22:39:19.026352782 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3106, /**/ -- Where do you want to crash today? /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///