Skip to content

Commit 0fad47b

Browse files
author
dlsmith
committed
DynamicJava: Fix for bug 2974931 -- division by zero causes exception during static checking.
git-svn-id: file:///tmp/test-svn/trunk@5214 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent ead4346 commit 0fad47b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

dynamicjava/src/edu/rice/cs/dynamicjava/interpreter/ExpressionChecker.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
import edu.rice.cs.plt.tuple.Option;
8181
import edu.rice.cs.plt.lambda.Lambda;
8282
import edu.rice.cs.plt.lambda.Lambda2;
83+
import edu.rice.cs.plt.lambda.WrappedException;
8384

8485
import edu.rice.cs.dynamicjava.Options;
8586
import edu.rice.cs.dynamicjava.symbol.*;
@@ -1583,13 +1584,21 @@ private Type handleBooleanExpression(BinaryExpression node) {
15831584

15841585
private void evaluateConstantExpression(BinaryExpression node) {
15851586
if (hasValue(node.getLeftExpression()) && hasValue(node.getRightExpression())) {
1586-
setValue(node, new ExpressionEvaluator(RuntimeBindings.EMPTY, opt).value(node));
1587+
try {
1588+
Object val = new ExpressionEvaluator(RuntimeBindings.EMPTY, opt).value(node);
1589+
setValue(node, val);
1590+
}
1591+
catch (WrappedException e) { /* failed to evaluate -- just ignore */ }
15871592
}
15881593
}
15891594

15901595
private void evaluateConstantExpression(UnaryExpression node) {
15911596
if (hasValue(node.getExpression())) {
1592-
setValue(node, new ExpressionEvaluator(RuntimeBindings.EMPTY, opt).value(node));
1597+
try {
1598+
Object val = new ExpressionEvaluator(RuntimeBindings.EMPTY, opt).value(node);
1599+
setValue(node, val);
1600+
}
1601+
catch (WrappedException e) { /* failed to evaluate -- just ignore */ }
15931602
}
15941603
}
15951604

0 commit comments

Comments
 (0)