diff src/testdir/test_vim9_func.vim @ 21685:26a4b53c4587 v8.2.1392

patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines Commit: https://github.com/vim/vim/commit/bf8feb5aeb71c8f56897845c4134793201aa459a Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 8 14:26:31 2020 +0200 patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines Problem: Vim9: error line number incorrect after skipping over comment lines. Solution: Insert empty lines for skipped lines.
author Bram Moolenaar <Bram@vim.org>
date Sat, 08 Aug 2020 14:30:04 +0200
parents 9a2ce62b93e9
children 10866fd07595
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -984,6 +984,47 @@ func DelMe()
   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")',