]> granicus.if.org Git - vim/commitdiff
patch 8.2.3352: Vim9: error for nested :enddef has wrong line number v8.2.3352
authorBram Moolenaar <Bram@vim.org>
Sun, 15 Aug 2021 17:28:05 +0000 (19:28 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 15 Aug 2021 17:28:05 +0000 (19:28 +0200)
Problem:    Vim9: error for nested :enddef has wrong line number.
Solution:   Compute the line number.

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

index c42188e7a83b79df7ca47a9997151684edeb705f..0ffe68632fe327b979afeb30439433b67d5ed65e 100644 (file)
@@ -630,6 +630,17 @@ def Test_nested_function()
       assert_equal(2, Test())
   END
   CheckScriptSuccess(lines)
+
+  lines =<< trim END
+      vim9script
+      def Outer()
+        def Inner()
+          echo 'hello'
+        enddef burp
+      enddef
+      defcompile
+  END
+  CheckScriptFailure(lines, 'E1173: Text found after enddef: burp', 3)
 enddef
 
 def Test_not_nested_function()
index 7a7617f5eb7422fe8bb81f6edfbce6a01828dfe9..86a2bec4eb5ddb893652b7c4c4d62d308517ffcd 100644 (file)
@@ -822,6 +822,8 @@ get_function_body(
                    else if (*p != NUL && *p != (vim9_function ? '#' : '"')
                                           && (vim9_function || p_verbose > 0))
                    {
+                       SOURCING_LNUM = sourcing_lnum_top
+                                                       + newlines->ga_len + 1;
                        if (eap->cmdidx == CMD_def)
                            semsg(_(e_text_found_after_enddef_str), p);
                        else
index 22022c815ce3af4a0a994b8c1a7809a6dd170a9a..95e53312dc61b0d0663c43a85979f3cc55ea4a79 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3352,
 /**/
     3351,
 /**/