Skip to content

Commit

Permalink
Bug: Wrong line in error message for arith. errors
Browse files Browse the repository at this point in the history
It also causes 'L->top' to be wrong when the error happens,
triggering an 'assert'.
  • Loading branch information
roberto-ieru committed Feb 8, 2023
1 parent 5e08b41 commit 02bab9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 1410,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
vmbreak;
}
vmcase(OP_MODK) {
savestate(L, ci); /* in case of division by 0 */
op_arithK(L, luaV_mod, luaV_modf);
vmbreak;
}
Expand All @@ -1422,6 1423,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
vmbreak;
}
vmcase(OP_IDIVK) {
savestate(L, ci); /* in case of division by 0 */
op_arithK(L, luaV_idiv, luai_numidiv);
vmbreak;
}
Expand Down Expand Up @@ -1470,6 1472,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
vmbreak;
}
vmcase(OP_MOD) {
savestate(L, ci); /* in case of division by 0 */
op_arith(L, luaV_mod, luaV_modf);
vmbreak;
}
Expand All @@ -1482,6 1485,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
vmbreak;
}
vmcase(OP_IDIV) { /* floor division */
savestate(L, ci); /* in case of division by 0 */
op_arith(L, luaV_idiv, luai_numidiv);
vmbreak;
}
Expand Down
8 changes: 8 additions & 0 deletions testes/errors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 444,14 @@ if not b then
end
end]], 5)


-- bug in 5.4.0
lineerror([[
local a = 0
local b = 1
local c = b % a
]], 3)

do
-- Force a negative estimate for base line. Error in instruction 2
-- (after VARARGPREP, GETGLOBAL), with first absolute line information
Expand Down

0 comments on commit 02bab9f

Please sign in to comment.