aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-06-03 12:13:13 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-06-03 12:13:13 -0300
commit4a3fd8488d617aa633f6b8be85e662653b100a59 (patch)
tree1dcc7fa6a6cec21619cb833be6f4a89ccc95404f
parent2c68e66570206aa1496f9c76fcf2a1a0f550d692 (diff)
downloadlua-4a3fd8488d617aa633f6b8be85e662653b100a59.tar.gz
lua-4a3fd8488d617aa633f6b8be85e662653b100a59.tar.bz2
lua-4a3fd8488d617aa633f6b8be85e662653b100a59.zip
bug in 5.4 alpha rc1: to-be-closed x vararg functions
Closing methods must be run before correcting 'ci->func' when exiting a vararg function, to get correct debug information (e.g., in case of errors).
-rw-r--r--lvm.c2
-rw-r--r--testes/locals.lua9
2 files changed, 10 insertions, 1 deletions
diff --git a/lvm.c b/lvm.c
index d7000791..5d0709ef 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1593,9 +1593,9 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1593 savepc(ci); 1593 savepc(ci);
1594 if (TESTARG_k(i)) { 1594 if (TESTARG_k(i)) {
1595 int nparams1 = GETARG_C(i); 1595 int nparams1 = GETARG_C(i);
1596 luaF_close(L, base, LUA_OK); /* there may be open upvalues */
1596 if (nparams1) /* vararg function? */ 1597 if (nparams1) /* vararg function? */
1597 ci->func -= ci->u.l.nextraargs + nparams1; 1598 ci->func -= ci->u.l.nextraargs + nparams1;
1598 luaF_close(L, base, LUA_OK); /* there may be open upvalues */
1599 } 1599 }
1600 luaD_poscall(L, ci, n); 1600 luaD_poscall(L, ci, n);
1601 return; 1601 return;
diff --git a/testes/locals.lua b/testes/locals.lua
index e59ab95a..7834d7da 100644
--- a/testes/locals.lua
+++ b/testes/locals.lua
@@ -276,6 +276,15 @@ do -- errors in __close
276 assert(msg == 1) 276 assert(msg == 1)
277 assert(log[1] == 4 and log[2] == 3 and log[3] == 2 and log[4] == 2 277 assert(log[1] == 4 and log[2] == 3 and log[3] == 2 and log[4] == 2
278 and #log == 4) 278 and #log == 4)
279
280 -- error in toclose in vararg function
281 function foo (...)
282 local <toclose> x123 = 10
283 end
284
285 local st, msg = pcall(foo)
286 assert(string.find(msg, "'x123'"))
287
279end 288end
280 289
281 290