To: vim_dev@googlegroups.com Subject: Patch 8.2.3126 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3126 Problem: Vim9: for loop error reports wrong line number. Solution: Save and restore the line number when evaluating the expression. (closes #8514) Files: src/ex_eval.c, src/testdir/test_vim9_script.vim *** ../vim-8.2.3125/src/ex_eval.c 2021-07-04 14:47:27.451118495 +0200 --- src/ex_eval.c 2021-07-08 19:20:02.842763879 +0200 *************** *** 1225,1233 **** --- 1225,1238 ---- } else { + long save_lnum = SOURCING_LNUM; + // Evaluate the argument and get the info in a structure. fi = eval_for_line(eap->arg, &error, eap, &evalarg); cstack->cs_forinfo[cstack->cs_idx] = fi; + + // Errors should use the first line number. + SOURCING_LNUM = save_lnum; } // use the element at the start of the list and advance *** ../vim-8.2.3125/src/testdir/test_vim9_script.vim 2021-07-08 17:35:33.136379926 +0200 --- src/testdir/test_vim9_script.vim 2021-07-08 19:18:06.010903029 +0200 *************** *** 2545,2550 **** --- 2545,2551 ---- CheckDefAndScriptFailure(['for # in range(5)'], 'E690:') CheckDefAndScriptFailure(['for i In range(5)'], 'E690:') CheckDefAndScriptFailure2(['var x = 5', 'for x in range(5)', 'endfor'], 'E1017:', 'E1041:') + CheckScriptFailure(['vim9script', 'var x = 5', 'for x in range(5)', '# comment', 'endfor'], 'E1041:', 3) CheckScriptFailure(['def Func(arg: any)', 'for arg in range(5)', 'enddef', 'defcompile'], 'E1006:') delfunc! g:Func CheckDefFailure(['for i in xxx'], 'E1001:') *** ../vim-8.2.3125/src/version.c 2021-07-08 18:04:57.185627006 +0200 --- src/version.c 2021-07-08 19:19:01.850836760 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3126, /**/ -- hundred-and-one symptoms of being an internet addict: 93. New mail alarm on your palmtop annoys other churchgoers. /// 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 ///