Skip to content

Commit

Permalink
Fix for OperatorOverloading.makeEnumOperator.
Browse files Browse the repository at this point in the history
- Change makeEnumOperator so it doesn't return both types when only the
  second is an enumeration, so that type checking of operations doesn't
  always succeed as long as the second operand has an enumeration type.
  • Loading branch information
perost authored and OpenModelica-Hudson committed Sep 30, 2017
1 parent 9670ad9 commit 453e1c7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Compiler/FrontEnd/OperatorOverloading.mo
Expand Up @@ -1183,33 +1183,33 @@ function makeEnumOperator
input DAE.Type inType2;
output tuple<DAE.Operator, list<DAE.Type>, DAE.Type> outOp;
algorithm
outOp := matchcontinue(inOp, inType1, inType2)
outOp := matchcontinue(inType1, inType2)
local
DAE.Type op_ty;
DAE.Operator op;

case (_, DAE.T_ENUMERATION(), DAE.T_ENUMERATION())
case (DAE.T_ENUMERATION(), DAE.T_ENUMERATION())
equation
op_ty = Types.simplifyType(inType1);
op = Expression.setOpType(inOp, op_ty);
then ((op, {inType1, inType2}, DAE.T_BOOL_DEFAULT));
then
((op, {inType1, inType2}, DAE.T_BOOL_DEFAULT));

case (_, DAE.T_ENUMERATION(), _)
case (DAE.T_ENUMERATION(), _)
equation
op_ty = Types.simplifyType(inType1);
op = Expression.setOpType(inOp, op_ty);
then
((op, {inType1, inType1}, DAE.T_BOOL_DEFAULT));

case (_, _, DAE.T_ENUMERATION())
case (_, DAE.T_ENUMERATION())
equation
op_ty = Types.simplifyType(inType1);
op_ty = Types.simplifyType(inType2);
op = Expression.setOpType(inOp, op_ty);
then
((op, {inType1, inType2}, DAE.T_BOOL_DEFAULT));
((op, {inType2, inType2}, DAE.T_BOOL_DEFAULT));

else
then ((inOp, {DAE.T_ENUMERATION_DEFAULT, DAE.T_ENUMERATION_DEFAULT}, DAE.T_BOOL_DEFAULT));
else ((inOp, {DAE.T_ENUMERATION_DEFAULT, DAE.T_ENUMERATION_DEFAULT}, DAE.T_BOOL_DEFAULT));
end matchcontinue;
end makeEnumOperator;

Expand Down

0 comments on commit 453e1c7

Please sign in to comment.