changeset 23444:7278e86c2f70 v8.2.2265

patch 8.2.2265: error message for missing endfunc/enddef is last line Commit: https://github.com/vim/vim/commit/b8ba9b919708f44b718c17f1fec85b1df8050a17 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 1 18:54:34 2021 +0100 patch 8.2.2265: error message for missing endfunc/enddef is last line Problem: Error message for missing endfunc/enddef is last line. Solution: Report the line where the function starts. (closes https://github.com/vim/vim/issues/7582)
author Bram Moolenaar <Bram@vim.org>
date Fri, 01 Jan 2021 19:00:04 +0100
parents 99a660a781a7
children 311caf397f9b
files src/testdir/test_vim9_func.vim src/userfunc.c src/version.c
diffstat 3 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -98,6 +98,24 @@ def Test_endfunc_enddef()
   CheckScriptFailure(lines, 'E1152:', 4)
 enddef
 
+def Test_missing_endfunc_enddef()
+  var lines =<< trim END
+    vim9script
+    def Test()
+      echo 'test'
+    endef
+  END
+  CheckScriptFailure(lines, 'E1057:', 2)
+
+  lines =<< trim END
+    vim9script
+    func Some()
+      echo 'test'
+    enfffunc
+  END
+  CheckScriptFailure(lines, 'E126:', 2)
+enddef
+
 def ReturnString(): string
   return 'string'
 enddef
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -3352,6 +3352,8 @@ define_function(exarg_T *eap, char_u *na
 	    lines_left = Rows - 1;
 	if (theline == NULL)
 	{
+	    // Use the start of the function for the line number.
+	    SOURCING_LNUM = sourcing_lnum_top;
 	    if (skip_until != NULL)
 		semsg(_(e_missing_heredoc_end_marker_str), skip_until);
 	    else if (eap->cmdidx == CMD_def)
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2265,
+/**/
     2264,
 /**/
     2263,