# HG changeset patch # User Bram Moolenaar # Date 1637445604 -3600 # Node ID 9e5e331828da78a89d4818d7749ac71bba9e625f # Parent b22360f54fad96ba93f2663fa8cbb5cd4a7e241e patch 8.2.3634: error for already defined function uses wrong line number Commit: https://github.com/vim/vim/commit/d604d78e7b2e63d118814d0fa0b4b702ec52aeed Author: Bram Moolenaar Date: Sat Nov 20 21:46:20 2021 +0000 patch 8.2.3634: error for already defined function uses wrong line number Problem: Error for already defined function uses wrong line number. Solution: Set SOURCING_LNUM before giving the error message. (closes https://github.com/vim/vim/issues/9085) diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim --- 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 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -4256,6 +4256,7 @@ define_function(exarg_T *eap, char_u *na && (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 --- 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,