Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1:/tmp/cvs-serv18371/F:/nice/src/bossa/syntax
Modified Files:
typecheck.nice
Log Message:
Changed error message for boolean conditions. fixes "bug" #750432 .
Index: typecheck.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v
retrieving revision 1.71
retrieving revision 1.72
diff -C2 -d -r1.71 -r1.72
*** typecheck.nice 27 May 2003 23:42:15 -0000 1.71
--- typecheck.nice 11 Jun 2003 17:39:33 -0000 1.72
***************
*** 363,378 ****
Expression elseExp = notNull(e.elseExp);
! try{
! condition = condition.resolveOverloading(PrimitiveType.boolPolytype);
! checkAssignment(PrimitiveType.boolPolytype, condition);
! e.condition = condition;
! }
! catch(TypingEx t){
! if (notNullError(t, e, condition.toString()))
! throw new bossa.util.UserError
! (e,
! "The condition must be a boolean.\n" +
! condition + " has type " + condition.getType());
! }
enterIf();
--- 363,369 ----
Expression elseExp = notNull(e.elseExp);
! condition = condition.resolveOverloading(PrimitiveType.boolPolytype);
! checkBooleanCondition(condition);
! e.condition = condition;
enterIf();
***************
*** 614,627 ****
{
l.whileExp = whileExp = whileExp.resolveOverloading(PrimitiveType.boolPolytype);
! try {
! checkAssignment(PrimitiveType.boolPolytype, whileExp);
! }
! catch(TypingEx t) {
! if (notNullError(t, l, whileExp.toString()))
! throw new bossa.util.UserError
! (whileExp,
! "The condition must be a boolean.\n" +
! whileExp + " has type " + whileExp.getType());
! }
}
--- 605,609 ----
{
l.whileExp = whileExp = whileExp.resolveOverloading(PrimitiveType.boolPolytype);
! checkBooleanCondition(whileExp);
}
***************
*** 769,772 ****
--- 751,766 ----
return true;
}
+
+ void checkBooleanCondition(Expression condition) {
+ try {
+ checkAssignment(PrimitiveType.boolPolytype, condition);
+ }
+ catch(TypingEx t){
+ throw new bossa.util.UserError(condition,
+ "The condition must be a boolean.\n" +
+ condition + " has type " + condition.getType());
+ }
+ }
+
void wrongReturnType(bossa.util.Located responsible,
|