Fixed divide-by-zero bug

This commit is contained in:
danielyxie 2017-08-15 19:18:04 -05:00
parent 63da40689d
commit 4e2c21b1ba

@ -270,7 +270,11 @@ function evalBinary(exp, workerScript){
resolve(expLeft*expRight);
break;
case "/":
resolve(expLeft/expRight);
if (expRight === 0) {
reject(makeRuntimeRejectMsg(workerScript, "ERROR: Divide by zero"));
} else {
resolve(expLeft/expRight);
}
break;
case "%":
resolve(expLeft%expRight);