summaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-11-16 09:55:27 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-11-16 09:55:27 -0200
commit521a452f2831f21bff7c46a894a1b269a7aec1b0 (patch)
treeff1627ad2c81e168cfef5279ce67a214b0849968 /lcode.c
parent2753134a3800eb28185502d68c28d9225420bd04 (diff)
downloadlua-521a452f2831f21bff7c46a894a1b269a7aec1b0.tar.gz
lua-521a452f2831f21bff7c46a894a1b269a7aec1b0.tar.bz2
lua-521a452f2831f21bff7c46a894a1b269a7aec1b0.zip
'mod' may also raise an error when applied to zero
Diffstat (limited to '')
-rw-r--r--lcode.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lcode.c b/lcode.c
index 16c698a7..3ca3a459 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 2.20 2005/10/24 17:37:52 roberto Exp roberto $ 2** $Id: lcode.c,v 2.21 2005/11/08 19:44:31 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -639,7 +639,9 @@ static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
639 case OP_DIV: 639 case OP_DIV:
640 if (v2 == 0) return 0; /* do not attempt to divide by 0 */ 640 if (v2 == 0) return 0; /* do not attempt to divide by 0 */
641 r = luai_numdiv(v1, v2); break; 641 r = luai_numdiv(v1, v2); break;
642 case OP_MOD: r = luai_nummod(v1, v2); break; 642 case OP_MOD:
643 if (v2 == 0) return 0; /* do not attempt to divide by 0 */
644 r = luai_nummod(v1, v2); break;
643 case OP_POW: r = luai_numpow(v1, v2); break; 645 case OP_POW: r = luai_numpow(v1, v2); break;
644 case OP_UNM: r = luai_numunm(v1); break; 646 case OP_UNM: r = luai_numunm(v1); break;
645 case OP_LEN: return 0; /* no constant folding for 'len' */ 647 case OP_LEN: return 0; /* no constant folding for 'len' */