]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.2265: error message for missing endfunc/enddef is last line v8.2.2265
authorBram Moolenaar <Bram@vim.org>
Fri, 1 Jan 2021 17:54:34 +0000 (18:54 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 1 Jan 2021 17:54:34 +0000 (18:54 +0100)
Problem:    Error message for missing endfunc/enddef is last line.
Solution:   Report the line where the function starts. (closes #7582)

src/testdir/test_vim9_func.vim
src/userfunc.c
src/version.c

index 223b2fbda7703a1d50345847c1632218df413184..20ad3ba8e4e02fea74b69095f69caf1768fdedf9 100644 (file)
@@ -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
index f0877e1c3bd468cbc50f01e1f3dbc9cc059b2094..5fab412b40c7d852a2d4803a82d144dad96b40b8 100644 (file)
@@ -3352,6 +3352,8 @@ define_function(exarg_T *eap, char_u *name_arg)
            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)
index 3fc3c01e1d23e28920534b6d34397c2a19fe9beb..770c1c75a170769faf5bdcb3baf741a8efe6760e 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2265,
 /**/
     2264,
 /**/