Skip to content

Commit

Permalink
[NB] correctly flatten array types (#9953)
Browse files Browse the repository at this point in the history
* [NB] correctly flatten array types

  - also allow simplify to apply type to scope
  - fixes #9946
  • Loading branch information
kabdelhak committed Dec 16, 2022
1 parent bd9195f commit f05ab45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions OMCompiler/Compiler/NFFrontEnd/NFFlatten.mo
Expand Up @@ -1062,16 +1062,21 @@ algorithm
for eq in eql loop
equations := match eq
local
Type ty;
InstNode iter, scope;
list<InstNode> iters;
Expression range;
Expression lhs, rhs, range;
list<Expression> ranges;
list<Subscript> subs;
DAE.ElementSource src;

// convert simple equality of crefs to array equality
case Equation.EQUALITY(lhs = Expression.CREF(), rhs = Expression.CREF())
then Equation.ARRAY_EQUALITY(eq.lhs, eq.rhs, Type.liftArrayLeftList(eq.ty, dimensions), eq.scope, eq.source) :: equations;
case Equation.EQUALITY(lhs = lhs as Expression.CREF(), rhs = rhs as Expression.CREF())
algorithm
ty := Type.liftArrayLeftList(eq.ty, dimensions);
lhs := Expression.CREF(ty, lhs.cref);
rhs := Expression.CREF(ty, rhs.cref);
then Equation.ARRAY_EQUALITY(lhs, rhs, ty, eq.scope, eq.source) :: equations;

// wrap general equation into for loop
else
Expand Down
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/NFFrontEnd/NFSimplifyExp.mo
Expand Up @@ -81,7 +81,7 @@ algorithm
case Expression.CREF()
algorithm
exp.cref := ComponentRef.simplifySubscripts(exp.cref);
exp.ty := ComponentRef.getSubscriptedType(exp.cref);
exp.ty := ComponentRef.getSubscriptedType(exp.cref, true);
then
exp;

Expand Down

0 comments on commit f05ab45

Please sign in to comment.