diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-11-20 21:46:20 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-11-20 21:46:20 +0000 |
commit | d604d78e7b2e63d118814d0fa0b4b702ec52aeed (patch) | |
tree | 6985954065d036b8259dbaa95d614b0befa09215 | |
parent | a755fdbe80bed4897e06028f0044c208e0f9d8cb (diff) |
patch 8.2.3634: error for already defined function uses wrong line numberv8.2.3634
Problem: Error for already defined function uses wrong line number.
Solution: Set SOURCING_LNUM before giving the error message. (closes #9085)
-rw-r--r-- | src/testdir/test_vim9_func.vim | 13 | ||||
-rw-r--r-- | src/userfunc.c | 1 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index c8b821e751..34f84f251a 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -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() diff --git a/src/userfunc.c b/src/userfunc.c index 95d9c4a94b..602d3b79e1 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -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 diff --git a/src/version.c b/src/version.c index b53524ff1d..fbbc961bc6 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3634, +/**/ 3633, /**/ 3632, |