mirror of https://github.com/rusefi/lua.git
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).
This commit is contained in:
parent
2c68e66570
commit
4a3fd8488d
2
lvm.c
2
lvm.c
|
@ -1593,9 +1593,9 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
|
||||||
savepc(ci);
|
savepc(ci);
|
||||||
if (TESTARG_k(i)) {
|
if (TESTARG_k(i)) {
|
||||||
int nparams1 = GETARG_C(i);
|
int nparams1 = GETARG_C(i);
|
||||||
|
luaF_close(L, base, LUA_OK); /* there may be open upvalues */
|
||||||
if (nparams1) /* vararg function? */
|
if (nparams1) /* vararg function? */
|
||||||
ci->func -= ci->u.l.nextraargs + nparams1;
|
ci->func -= ci->u.l.nextraargs + nparams1;
|
||||||
luaF_close(L, base, LUA_OK); /* there may be open upvalues */
|
|
||||||
}
|
}
|
||||||
luaD_poscall(L, ci, n);
|
luaD_poscall(L, ci, n);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -276,6 +276,15 @@ do -- errors in __close
|
||||||
assert(msg == 1)
|
assert(msg == 1)
|
||||||
assert(log[1] == 4 and log[2] == 3 and log[3] == 2 and log[4] == 2
|
assert(log[1] == 4 and log[2] == 3 and log[3] == 2 and log[4] == 2
|
||||||
and #log == 4)
|
and #log == 4)
|
||||||
|
|
||||||
|
-- error in toclose in vararg function
|
||||||
|
function foo (...)
|
||||||
|
local <toclose> x123 = 10
|
||||||
|
end
|
||||||
|
|
||||||
|
local st, msg = pcall(foo)
|
||||||
|
assert(string.find(msg, "'x123'"))
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue