mirror of
https://github.com/lua/lua
synced 2025-04-08 14:02:56 +03:00
Bug: Wrong line number for function calls
This commit is contained in:
parent
9b4f39ab14
commit
5ab6a5756b
12
lparser.c
12
lparser.c
@ -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;
|
FuncState *fs = ls->fs;
|
||||||
expdesc args;
|
expdesc args;
|
||||||
int base, nparams;
|
int base, nparams;
|
||||||
|
int line = ls->linenumber;
|
||||||
switch (ls->t.token) {
|
switch (ls->t.token) {
|
||||||
case '(': { /* funcargs -> '(' [ explist ] ')' */
|
case '(': { /* funcargs -> '(' [ explist ] ')' */
|
||||||
luaX_next(ls);
|
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));
|
init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));
|
||||||
luaK_fixline(fs, line);
|
luaK_fixline(fs, line);
|
||||||
fs->freereg = base+1; /* call remove function and arguments and leaves
|
fs->freereg = base+1; /* call removes function and arguments and leaves
|
||||||
(unless changed) one result */
|
one result (unless changed later) */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1103,7 +1104,6 @@ static void suffixedexp (LexState *ls, expdesc *v) {
|
|||||||
/* suffixedexp ->
|
/* suffixedexp ->
|
||||||
primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */
|
primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
int line = ls->linenumber;
|
|
||||||
primaryexp(ls, v);
|
primaryexp(ls, v);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
switch (ls->t.token) {
|
switch (ls->t.token) {
|
||||||
@ -1123,12 +1123,12 @@ static void suffixedexp (LexState *ls, expdesc *v) {
|
|||||||
luaX_next(ls);
|
luaX_next(ls);
|
||||||
codename(ls, &key);
|
codename(ls, &key);
|
||||||
luaK_self(fs, v, &key);
|
luaK_self(fs, v, &key);
|
||||||
funcargs(ls, v, line);
|
funcargs(ls, v);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '(': case TK_STRING: case '{': { /* funcargs */
|
case '(': case TK_STRING: case '{': { /* funcargs */
|
||||||
luaK_exp2nextreg(fs, v);
|
luaK_exp2nextreg(fs, v);
|
||||||
funcargs(ls, v, line);
|
funcargs(ls, v);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: return;
|
default: return;
|
||||||
|
@ -392,19 +392,19 @@ lineerror("a\n=\n-\n\nprint\n;", 3)
|
|||||||
|
|
||||||
lineerror([[
|
lineerror([[
|
||||||
a
|
a
|
||||||
(
|
( -- <<
|
||||||
23)
|
23)
|
||||||
]], 1)
|
]], 2)
|
||||||
|
|
||||||
lineerror([[
|
lineerror([[
|
||||||
local a = {x = 13}
|
local a = {x = 13}
|
||||||
a
|
a
|
||||||
.
|
.
|
||||||
x
|
x
|
||||||
(
|
( -- <<
|
||||||
23
|
23
|
||||||
)
|
)
|
||||||
]], 2)
|
]], 5)
|
||||||
|
|
||||||
lineerror([[
|
lineerror([[
|
||||||
local a = {x = 13}
|
local a = {x = 13}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user