Browse Source

Fixed a bug where the type of multi was not correctly determined if boolean arguments came before double arguments. Now we enforce doubles to be given first.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@11076 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Vojtech Forejt 10 years ago
parent
commit
2d8194398b
  1. 9
      prism/src/parser/visitor/TypeCheck.java

9
prism/src/parser/visitor/TypeCheck.java

@ -371,12 +371,19 @@ public class TypeCheck extends ASTTraverse
} }
break; break;
case ExpressionFunc.MULTI: case ExpressionFunc.MULTI:
// All operands must be booleans or doubles
// All operands must be booleans or doubles, and doubles must come first.
boolean seenBoolean = false;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (!(types[i] instanceof TypeBool || types[i] instanceof TypeDouble)) { if (!(types[i] instanceof TypeBool || types[i] instanceof TypeDouble)) {
throw new PrismLangException("Type error: non-Boolean/Double argument to function \"" + e.getName() throw new PrismLangException("Type error: non-Boolean/Double argument to function \"" + e.getName()
+ "\"", e.getOperand(i)); + "\"", e.getOperand(i));
} }
if (seenBoolean && types[i] instanceof TypeDouble) {
throw new PrismLangException("Type error: in the function \"" + e.getName() + "\", any Double arguments must come before any Boolean arguments.");
}
if (types[i] instanceof TypeBool) {
seenBoolean = true;
}
} }
break; break;
default: default:

Loading…
Cancel
Save