Browse Source

Fix constant evaluation "bug" in ConstantsList which is never actually triggered.

accumulation-v4.7
Dave Parker 8 years ago
parent
commit
730677bab6
  1. 6
      prism/src/parser/ast/ConstantList.java

6
prism/src/parser/ast/ConstantList.java

@ -353,9 +353,11 @@ public class ConstantList extends ASTElement
allValues = new Values(); allValues = new Values();
for (i = 0; i < numToEvaluate; i++) { for (i = 0; i < numToEvaluate; i++) {
Expression constant = cl.getConstant(i); Expression constant = cl.getConstant(i);
// NB: We use otherValues when evaluating here, but that shouldn't be needed
// since these values have already been plugged in by expandConstants above
if (constant != null) { if (constant != null) {
if (exact) { if (exact) {
BigRational r = constant.evaluateExact(null, otherValues);
BigRational r = constant.evaluateExact(otherValues);
// handle differently, depending on constant type // handle differently, depending on constant type
if (constant.getType() instanceof TypeDouble) { if (constant.getType() instanceof TypeDouble) {
// we keep as BigRational for TypeDouble // we keep as BigRational for TypeDouble
@ -367,7 +369,7 @@ public class ConstantList extends ASTElement
val = constant.getType().castFromBigRational(r); val = constant.getType().castFromBigRational(r);
} }
} else { } else {
val = constant.evaluate(null, otherValues);
val = constant.evaluate(otherValues);
} }
allValues.addValue(cl.getConstantName(i), val); allValues.addValue(cl.getConstantName(i), val);
} }

Loading…
Cancel
Save