0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00

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 #8100)
This commit is contained in:
Bram Moolenaar 2021-04-12 22:02:36 +02:00
parent 68452177ca
commit f48b2fa33c
3 changed files with 30 additions and 0 deletions

View File

@ -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

View File

@ -4058,7 +4058,11 @@ define_function(exarg_T *eap, char_u *name_arg)
}
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;
}
}

View File

@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2758,
/**/
2757,
/**/