]> granicus.if.org Git - vim/commitdiff
patch 8.2.3634: error for already defined function uses wrong line number v8.2.3634
authorBram Moolenaar <Bram@vim.org>
Sat, 20 Nov 2021 21:46:20 +0000 (21:46 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 20 Nov 2021 21:46:20 +0000 (21:46 +0000)
Problem:    Error for already defined function uses wrong line number.
Solution:   Set SOURCING_LNUM before giving the error message. (closes #9085)

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

index c8b821e75102824d154f3c53bce94a4edc284ea8..34f84f251acb564bbc237cacb03adde79abf945d 100644 (file)
@@ -741,7 +741,18 @@ def Test_nested_global_function()
       enddef
       defcompile
   END
-  CheckScriptFailure(lines, "E1073:")
+  CheckScriptFailure(lines, "E1073:", 1)
+
+  lines =<< trim END
+      vim9script
+      def Func()
+        echo 'script'
+      enddef
+      def Func()
+        echo 'script'
+      enddef
+  END
+  CheckScriptFailure(lines, "E1073:", 5)
 enddef
 
 def DefListAll()
index 95d9c4a94bd3d82ed9b50c15e0c1a9bf53d46f85..602d3b79e1e50826e91c55617fb707f5f037b503 100644 (file)
@@ -4256,6 +4256,7 @@ define_function(exarg_T *eap, char_u *name_arg)
                        && (fp->uf_script_ctx.sc_sid != current_sctx.sc_sid
                          || fp->uf_script_ctx.sc_seq == current_sctx.sc_seq)))
            {
+               SOURCING_LNUM = sourcing_lnum_top;
                if (vim9script)
                    emsg_funcname(e_name_already_defined_str, name);
                else
index b53524ff1d7800ce642c293b8f15390a24aa0e2c..fbbc961bc6bb30d86eec935b37f7af7bc718f04b 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3634,
 /**/
     3633,
 /**/