Skip to content

Commit

Permalink
fix ticket:4190 allow arrays components in when conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
adrpo authored and OpenModelica-Hudson committed Dec 17, 2016
1 parent 26d9240 commit 6757b53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Compiler/FrontEnd/InstSection.mo
Expand Up @@ -2933,9 +2933,16 @@ protected function checkWhenCondition
input DAE.Type ty;
input Absyn.Exp aexp;
input SourceInfo info;
protected
DAE.Type tyEl;
algorithm
try
exp := Types.matchType(exp, ty, DAE.T_BOOL_DEFAULT);
if Types.isArray(ty) then
tyEl := Types.arrayElementType(ty);
else
tyEl := ty;
end if;
exp := Types.matchType(exp, tyEl, DAE.T_BOOL_DEFAULT);
else
Error.addSourceMessage(Error.IF_CONDITION_TYPE_ERROR,{Dump.printExpStr(aexp),Types.unparseType(ty)},info);
fail();
Expand Down
4 changes: 4 additions & 0 deletions Compiler/FrontEnd/Types.mo
Expand Up @@ -2044,6 +2044,8 @@ algorithm
equation
(ty,dim) = unliftArrayOrList(ty);
then (ty,dim);
case (DAE.T_FUNCTION(funcResultType = ty))
then unliftArrayOrList(ty);
end match;
end unliftArrayOrList;

Expand All @@ -2058,6 +2060,8 @@ algorithm
then if listEmpty(getDimensions(inType.complexType)) then
inType else arrayElementType(inType.complexType);

case DAE.T_FUNCTION() then arrayElementType(inType.funcResultType);

else inType;
end match;
end arrayElementType;
Expand Down

0 comments on commit 6757b53

Please sign in to comment.