Bug: Wrong line number for function calls

This commit is contained in:
Roberto Ierusalimschy 2023-08-23 13:49:27 -03:00
parent 9b4f39ab14
commit 5ab6a5756b
2 changed files with 10 additions and 10 deletions

View File

@ -1022,10 +1022,11 @@ static int explist (LexState *ls, expdesc *v) {
}
static void funcargs (LexState *ls, expdesc *f, int line) {
static void funcargs (LexState *ls, expdesc *f) {
FuncState *fs = ls->fs;
expdesc args;
int base, nparams;
int line = ls->linenumber;
switch (ls->t.token) {
case '(': { /* funcargs -> '(' [ explist ] ')' */
luaX_next(ls);
@ -1063,8 +1064,8 @@ static void funcargs (LexState *ls, expdesc *f, int line) {
}
init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));
luaK_fixline(fs, line);
fs->freereg = base+1; /* call remove function and arguments and leaves
(unless changed) one result */
fs->freereg = base+1; /* call removes function and arguments and leaves
one result (unless changed later) */
}
@ -1103,7 +1104,6 @@ static void suffixedexp (LexState *ls, expdesc *v) {
/* suffixedexp ->
primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */
FuncState *fs = ls->fs;
int line = ls->linenumber;
primaryexp(ls, v);
for (;;) {
switch (ls->t.token) {
@ -1123,12 +1123,12 @@ static void suffixedexp (LexState *ls, expdesc *v) {
luaX_next(ls);
codename(ls, &key);
luaK_self(fs, v, &key);
funcargs(ls, v, line);
funcargs(ls, v);
break;
}
case '(': case TK_STRING: case '{': { /* funcargs */
luaK_exp2nextreg(fs, v);
funcargs(ls, v, line);
funcargs(ls, v);
break;
}
default: return;

View File

@ -392,19 +392,19 @@ lineerror("a\n=\n-\n\nprint\n;", 3)
lineerror([[
a
(
( -- <<
23)
]], 1)
]], 2)
lineerror([[
local a = {x = 13}
a
.
x
(
( -- <<
23
)
]], 2)
]], 5)
lineerror([[
local a = {x = 13}