0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.2.1481: Vim9: line number reported with error may be wrong

Problem:    Vim9: line number reported with error may be wrong.
Solution:   Check line number in tests.
This commit is contained in:
Bram Moolenaar
2020-08-18 20:34:13 +02:00
parent e15eebd202
commit 3affe7a6c6
4 changed files with 296 additions and 287 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -10,24 +10,28 @@ endfunc
" Check that "lines" inside ":def" results in an "error" message.
" If "lnum" is given check that the error is reported for this line.
func CheckDefFailure(lines, error, lnum = -1)
call writefile(['def Func()'] + a:lines + ['enddef', 'defcompile'], 'Xdef')
call assert_fails('so Xdef', a:error, a:lines, a:lnum)
" Add a line before and after to make it less likely that the line number is
" accidentally correct.
func CheckDefFailure(lines, error, lnum = -3)
call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef', 'defcompile'], 'Xdef')
call assert_fails('so Xdef', a:error, a:lines, a:lnum + 1)
call delete('Xdef')
endfunc
" Check that "lines" inside ":def" results in an "error" message when executed.
" If "lnum" is given check that the error is reported for this line.
func CheckDefExecFailure(lines, error, lnum = -1)
call writefile(['def Func()'] + a:lines + ['enddef'], 'Xdef')
" Add a line before and after to make it less likely that the line number is
" accidentally correct.
func CheckDefExecFailure(lines, error, lnum = -3)
call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef'], 'Xdef')
so Xdef
call assert_fails('call Func()', a:error, a:lines, a:lnum)
call assert_fails('call Func()', a:error, a:lines, a:lnum + 1)
call delete('Xdef')
endfunc
def CheckScriptFailure(lines: list<string>, error: string)
def CheckScriptFailure(lines: list<string>, error: string, lnum = -3)
writefile(lines, 'Xdef')
assert_fails('so Xdef', error, lines)
assert_fails('so Xdef', error, lines, lnum)
delete('Xdef')
enddef

View File

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

View File

@@ -2317,6 +2317,7 @@ call_def_function(
// slice: composite is at stack-3, indexes at stack-2 and
// stack-1
tv = is_slice ? STACK_TV_BOT(-3) : STACK_TV_BOT(-2);
SOURCING_LNUM = iptr->isn_lnum;
if (check_can_index(tv, TRUE, TRUE) == FAIL)
goto on_error;
var1 = is_slice ? STACK_TV_BOT(-2) : STACK_TV_BOT(-1);
@@ -2463,6 +2464,7 @@ call_def_function(
int error = FALSE;
tv = STACK_TV_BOT(-1);
SOURCING_LNUM = iptr->isn_lnum;
if (check_not_string(tv) == FAIL)
goto on_error;
(void)tv_get_number_chk(tv, &error);