aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-08-23 13:49:27 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-08-23 13:49:27 -0300
commit5ab6a5756b3c50c99f1388885e9a48a7da8cbe2d (patch)
tree8cee77510f5e919b7c4165370736aac779c8bd77
parent9b4f39ab14fb2e55345c3d23537d129dac23b091 (diff)
downloadlua-5ab6a5756b3c50c99f1388885e9a48a7da8cbe2d.tar.gz
lua-5ab6a5756b3c50c99f1388885e9a48a7da8cbe2d.tar.bz2
lua-5ab6a5756b3c50c99f1388885e9a48a7da8cbe2d.zip
Bug: Wrong line number for function calls
-rw-r--r--lparser.c12
-rw-r--r--testes/errors.lua8
2 files changed, 10 insertions, 10 deletions
diff --git a/lparser.c b/lparser.c
index b745f236..2b888c7c 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1022,10 +1022,11 @@ static int explist (LexState *ls, expdesc *v) {
1022} 1022}
1023 1023
1024 1024
1025static void funcargs (LexState *ls, expdesc *f, int line) { 1025static void funcargs (LexState *ls, expdesc *f) {
1026 FuncState *fs = ls->fs; 1026 FuncState *fs = ls->fs;
1027 expdesc args; 1027 expdesc args;
1028 int base, nparams; 1028 int base, nparams;
1029 int line = ls->linenumber;
1029 switch (ls->t.token) { 1030 switch (ls->t.token) {
1030 case '(': { /* funcargs -> '(' [ explist ] ')' */ 1031 case '(': { /* funcargs -> '(' [ explist ] ')' */
1031 luaX_next(ls); 1032 luaX_next(ls);
@@ -1063,8 +1064,8 @@ static void funcargs (LexState *ls, expdesc *f, int line) {
1063 } 1064 }
1064 init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); 1065 init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));
1065 luaK_fixline(fs, line); 1066 luaK_fixline(fs, line);
1066 fs->freereg = base+1; /* call remove function and arguments and leaves 1067 fs->freereg = base+1; /* call removes function and arguments and leaves
1067 (unless changed) one result */ 1068 one result (unless changed later) */
1068} 1069}
1069 1070
1070 1071
@@ -1103,7 +1104,6 @@ static void suffixedexp (LexState *ls, expdesc *v) {
1103 /* suffixedexp -> 1104 /* suffixedexp ->
1104 primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */ 1105 primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */
1105 FuncState *fs = ls->fs; 1106 FuncState *fs = ls->fs;
1106 int line = ls->linenumber;
1107 primaryexp(ls, v); 1107 primaryexp(ls, v);
1108 for (;;) { 1108 for (;;) {
1109 switch (ls->t.token) { 1109 switch (ls->t.token) {
@@ -1123,12 +1123,12 @@ static void suffixedexp (LexState *ls, expdesc *v) {
1123 luaX_next(ls); 1123 luaX_next(ls);
1124 codename(ls, &key); 1124 codename(ls, &key);
1125 luaK_self(fs, v, &key); 1125 luaK_self(fs, v, &key);
1126 funcargs(ls, v, line); 1126 funcargs(ls, v);
1127 break; 1127 break;
1128 } 1128 }
1129 case '(': case TK_STRING: case '{': { /* funcargs */ 1129 case '(': case TK_STRING: case '{': { /* funcargs */
1130 luaK_exp2nextreg(fs, v); 1130 luaK_exp2nextreg(fs, v);
1131 funcargs(ls, v, line); 1131 funcargs(ls, v);
1132 break; 1132 break;
1133 } 1133 }
1134 default: return; 1134 default: return;
diff --git a/testes/errors.lua b/testes/errors.lua
index bf6f389d..b777a329 100644
--- a/testes/errors.lua
+++ b/testes/errors.lua
@@ -392,19 +392,19 @@ lineerror("a\n=\n-\n\nprint\n;", 3)
392 392
393lineerror([[ 393lineerror([[
394a 394a
395( 395( -- <<
39623) 39623)
397]], 1) 397]], 2)
398 398
399lineerror([[ 399lineerror([[
400local a = {x = 13} 400local a = {x = 13}
401a 401a
402. 402.
403x 403x
404( 404( -- <<
40523 40523
406) 406)
407]], 2) 407]], 5)
408 408
409lineerror([[ 409lineerror([[
410local a = {x = 13} 410local a = {x = 13}