Mercurial > vim
changeset 26205:9e5e331828da v8.2.3634
patch 8.2.3634: error for already defined function uses wrong line number
Commit: https://github.com/vim/vim/commit/d604d78e7b2e63d118814d0fa0b4b702ec52aeed
Author: Bram Moolenaar <Bram@vim.org>
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 20 Nov 2021 23:00:04 +0100 |
parents | b22360f54fad |
children | 851db50bd99b |
files | src/testdir/test_vim9_func.vim src/userfunc.c src/version.c |
diffstat | 3 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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()
--- 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