summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-02-08 14:15:41 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-02-08 14:15:41 -0300
commit02bab9fc258fe1cbc6088b1bd61193499d058eff (patch)
treea88b03d4c84ac0d734d528f39f4fd9ead8819432
parent5e08b41567c5723c9f599d02a7511aa398f7c646 (diff)
downloadlua-github-02bab9fc258fe1cbc6088b1bd61193499d058eff.tar.gz
Bug: Wrong line in error message for arith. errors
It also causes 'L->top' to be wrong when the error happens, triggering an 'assert'.
-rw-r--r--lvm.c4
-rw-r--r--testes/errors.lua8
2 files changed, 12 insertions, 0 deletions
diff --git a/lvm.c b/lvm.c
index 2e84dc63..8493a770 100644
--- a/lvm.c
+++ b/lvm.c
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
diff --git a/testes/errors.lua b/testes/errors.lua
index cf0ab526..bf6f389d 100644
--- a/testes/errors.lua
+++ b/testes/errors.lua
@@ -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