From 2d8194398bb07c9b0582f00fbf398738df91d2b8 Mon Sep 17 00:00:00 2001 From: Vojtech Forejt Date: Tue, 22 Dec 2015 12:28:39 +0000 Subject: [PATCH] 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 --- prism/src/parser/visitor/TypeCheck.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/prism/src/parser/visitor/TypeCheck.java b/prism/src/parser/visitor/TypeCheck.java index 778a9cbb..187ee59e 100644 --- a/prism/src/parser/visitor/TypeCheck.java +++ b/prism/src/parser/visitor/TypeCheck.java @@ -371,12 +371,19 @@ public class TypeCheck extends ASTTraverse } break; 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++) { if (!(types[i] instanceof TypeBool || types[i] instanceof TypeDouble)) { throw new PrismLangException("Type error: non-Boolean/Double argument to function \"" + e.getName() + "\"", 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; default: