Visitar URL original
Bug: Wrong line in error message for arith. errors · lua/lua@02bab9f · GitHub
Skip to content

Commit 02bab9f

Browse files
committed
Bug: Wrong line in error message for arith. errors
It also causes 'L->top' to be wrong when the error happens, triggering an 'assert'.
1 parent 5e08b41 commit 02bab9f

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎lvm.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
14101410
vmbreak;
14111411
}
14121412
vmcase(OP_MODK) {
1413+
savestate(L, ci); /* in case of division by 0 */
14131414
op_arithK(L, luaV_mod, luaV_modf);
14141415
vmbreak;
14151416
}
@@ -1422,6 +1423,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
14221423
vmbreak;
14231424
}
14241425
vmcase(OP_IDIVK) {
1426+
savestate(L, ci); /* in case of division by 0 */
14251427
op_arithK(L, luaV_idiv, luai_numidiv);
14261428
vmbreak;
14271429
}
@@ -1470,6 +1472,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
14701472
vmbreak;
14711473
}
14721474
vmcase(OP_MOD) {
1475+
savestate(L, ci); /* in case of division by 0 */
14731476
op_arith(L, luaV_mod, luaV_modf);
14741477
vmbreak;
14751478
}
@@ -1482,6 +1485,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
14821485
vmbreak;
14831486
}
14841487
vmcase(OP_IDIV) { /* floor division */
1488+
savestate(L, ci); /* in case of division by 0 */
14851489
op_arith(L, luaV_idiv, luai_numidiv);
14861490
vmbreak;
14871491
}

‎testes/errors.lua‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,14 @@ if not b then
444444
end
445445
end]], 5)
446446

447+
448+
-- bug in 5.4.0
449+
lineerror([[
450+
local a = 0
451+
local b = 1
452+
local c = b % a
453+
]], 3)
454+
447455
do
448456
-- Force a negative estimate for base line. Error in instruction 2
449457
-- (after VARARGPREP, GETGLOBAL), with first absolute line information

0 commit comments

Comments
 (0)