Mercurial > vim
changeset 24436:ccdd5e9a3763 v8.2.2758
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Commit: https://github.com/vim/vim/commit/f48b2fa33cda94e963f6fa8b78f344385c9ebea6
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Apr 12 22:02:36 2021 +0200
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Problem: Vim9: wrong line number for autoload function with wrong name.
Solution: Set and restore SOURCING_LNUM. (closes https://github.com/vim/vim/issues/8100)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 12 Apr 2021 22:15:03 +0200 |
parents | 8a5865e08b2a |
children | c63e5ce43b69 |
files | src/testdir/test_vim9_func.vim src/userfunc.c src/version.c |
diffstat | 3 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -74,6 +74,30 @@ def TestCompilingErrorInTry() delete('Xdir', 'rf') enddef +def Test_autoload_name_mismatch() + var dir = 'Xdir/autoload' + mkdir(dir, 'p') + + var lines =<< trim END + vim9script + def scriptX#Function() + # comment + g:runtime = 'yes' + enddef + END + writefile(lines, dir .. '/script.vim') + + var save_rtp = &rtp + exe 'set rtp=' .. getcwd() .. '/Xdir' + lines =<< trim END + call script#Function() + END + CheckScriptFailure(lines, 'E746:', 2) + + &rtp = save_rtp + delete(dir, 'rf') +enddef + def CallRecursive(n: number): number return CallRecursive(n + 1) enddef
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -4058,7 +4058,11 @@ define_function(exarg_T *eap, char_u *na } if (j == FAIL) { + linenr_T save_lnum = SOURCING_LNUM; + + SOURCING_LNUM = sourcing_lnum_top; semsg(_("E746: Function name does not match script file name: %s"), name); + SOURCING_LNUM = save_lnum; goto erret; } }