mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-26 20:31:30 +00:00
Merge branch 'more-helpful-lua-error' into 'master'
Make "divide by zero" or "modulo by zero" errors show the file and line of where it happened See merge request KartKrew/Kart-Public!228
This commit is contained in:
commit
c575bc0398
1 changed files with 4 additions and 6 deletions
|
@ -322,8 +322,8 @@ static void Arith (lua_State *L, StkId ra, TValue *rb,
|
|||
case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
|
||||
case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
|
||||
case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
|
||||
case TM_DIV: if (nc == 0) { lua_pushliteral(L, "divide by zero error"); lua_error(L); } else setnvalue(ra, luai_numdiv(nb, nc)); break;
|
||||
case TM_MOD: if (nc == 0) { lua_pushliteral(L, "modulo by zero error"); lua_error(L); } else setnvalue(ra, luai_nummod(nb, nc)); break;
|
||||
case TM_DIV: if (nc == 0) { luaG_runerror(L, "divide by zero error"); } else setnvalue(ra, luai_numdiv(nb, nc)); break;
|
||||
case TM_MOD: if (nc == 0) { luaG_runerror(L, "modulo by zero error"); } else setnvalue(ra, luai_nummod(nb, nc)); break;
|
||||
case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
|
||||
case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
|
||||
case TM_AND: setnvalue(ra, luai_numand(nb, nc)); break;
|
||||
|
@ -492,8 +492,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
if (nc == 0) {
|
||||
lua_pushliteral(L, "divide by zero error");
|
||||
lua_error(L);
|
||||
luaG_runerror(L, "divide by zero error");
|
||||
}
|
||||
else
|
||||
setnvalue(ra, luai_numdiv(nb, nc));
|
||||
|
@ -508,8 +507,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
||||
if (nc == 0) {
|
||||
lua_pushliteral(L, "modulo by zero error");
|
||||
lua_error(L);
|
||||
luaG_runerror(L, "modulo by zero error");
|
||||
}
|
||||
else
|
||||
setnvalue(ra, luai_nummod(nb, nc));
|
||||
|
|
Loading…
Reference in a new issue