Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
[NF] Fix type when casting arrays.
Browse files Browse the repository at this point in the history
- When casting arrays in NFSimplifyExp.simplifyCast, don't just cast
  the elements but update the type of the array too.

Belonging to [master]:
  - #2927
  • Loading branch information
perost authored and OpenModelica-Hudson committed Feb 11, 2019
1 parent 2de3e75 commit a55f71c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Compiler/NFFrontEnd/NFSimplifyExp.mo
Expand Up @@ -667,11 +667,19 @@ function simplifyCast
output Expression castExp;
algorithm
castExp := match (ty, exp)
local
Type ety;

case (Type.REAL(), Expression.INTEGER())
then Expression.REAL(intReal(exp.value));

case (Type.ARRAY(elementType = Type.REAL()), Expression.ARRAY())
then Expression.mapArrayElements(exp, function simplifyCast(ty = Type.REAL()));
algorithm
ety := Type.unliftArray(ty);
exp.elements := list(simplifyCast(e, ety) for e in exp.elements);
exp.ty := Type.setArrayElementType(exp.ty, Type.arrayElementType(ty));
then
exp;

else Expression.CAST(ty, exp);
end match;
Expand Down

0 comments on commit a55f71c

Please sign in to comment.