Skip to content

Commit

Permalink
Fix function evaluation regression (#8575)
Browse files Browse the repository at this point in the history
- Don't create arrays with shared elements in
  Expression.fillType/fillArgs.
  • Loading branch information
perost committed Feb 18, 2022
1 parent caa8835 commit dfa5ea6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions OMCompiler/Compiler/NFFrontEnd/NFExpression.mo
Expand Up @@ -4227,7 +4227,7 @@ public
for dim in listReverse(dims) loop
expl := {};
for i in 1:Dimension.size(dim) loop
expl := exp :: expl;
expl := map(exp, clone) :: expl;
end for;

arr_ty := Type.liftArrayLeft(arr_ty, dim);
Expand All @@ -4250,7 +4250,7 @@ public
algorithm
for d in listReverse(dims) loop
dim_size := toInteger(d);
arr := list(result for e in 1:dim_size);
arr := list(map(result, clone) for e in 1:dim_size);
arr_ty := Type.liftArrayLeft(arr_ty, Dimension.fromInteger(dim_size));
result := makeArray(arr_ty, listArray(arr), is_literal);
end for;
Expand Down Expand Up @@ -5612,5 +5612,18 @@ public
end match;
end isComponentExpression;

function clone
input output Expression exp;
algorithm
() := match exp
case ARRAY()
algorithm
exp.elements := arrayCopy(exp.elements);
then
();
else ();
end match;
end clone;

annotation(__OpenModelica_Interface="frontend");
end NFExpression;

0 comments on commit dfa5ea6

Please sign in to comment.