To: vim_dev@googlegroups.com Subject: Patch 8.2.1392 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1392 Problem: Vim9: error line number incorrect after skipping over comment lines. Solution: Insert empty lines for skipped lines. Files: src/userfunc.c, src/testdir/test_vim9_func.vim *** ../vim-8.2.1391/src/userfunc.c 2020-08-05 14:34:08.935573705 +0200 --- src/userfunc.c 2020-08-08 14:22:53.505374746 +0200 *************** *** 2961,2966 **** --- 2961,2978 ---- // Save the starting line number. sourcing_lnum_top = SOURCING_LNUM; + // Detect having skipped over comment lines to find the return + // type. Add NULL lines to keep the line count correct. + sourcing_lnum_off = get_sourced_lnum(eap->getline, eap->cookie); + if (SOURCING_LNUM < sourcing_lnum_off) + { + sourcing_lnum_off -= SOURCING_LNUM; + if (ga_grow(&newlines, sourcing_lnum_off) == FAIL) + goto erret; + while (sourcing_lnum_off-- > 0) + ((char_u **)(newlines.ga_data))[newlines.ga_len++] = NULL; + } + indent = 2; nesting = 0; nesting_def[nesting] = (eap->cmdidx == CMD_def); *** ../vim-8.2.1391/src/testdir/test_vim9_func.vim 2020-08-06 21:26:54.436005498 +0200 --- src/testdir/test_vim9_func.vim 2020-08-08 14:24:06.261063703 +0200 *************** *** 984,989 **** --- 984,1030 ---- echo 'DelMe' endfunc + def Test_error_reporting() + # comment lines at the start of the function + let lines =<< trim END + " comment + def Func() + # comment + # comment + invalid + enddef + defcompile + END + call writefile(lines, 'Xdef') + try + source Xdef + catch /E476:/ + assert_match('Invalid command: invalid', v:exception) + assert_match(', line 3$', v:throwpoint) + endtry + + # comment lines after the start of the function + lines =<< trim END + " comment + def Func() + let x = 1234 + # comment + # comment + invalid + enddef + defcompile + END + call writefile(lines, 'Xdef') + try + source Xdef + catch /E476:/ + assert_match('Invalid command: invalid', v:exception) + assert_match(', line 4$', v:throwpoint) + endtry + + call delete('Xdef') + enddef + def Test_deleted_function() CheckDefExecFailure([ 'let RefMe: func = function("g:DelMe")', *** ../vim-8.2.1391/src/version.c 2020-08-07 22:00:22.643492517 +0200 --- src/version.c 2020-08-08 14:07:49.609544942 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1392, /**/ -- You are not really successful until someone claims he sat beside you in school. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///