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

Commit 04d541f

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Fix type when expanding unary expressions.
Belonging to [master]: - #2576
1 parent 06e511f commit 04d541f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Compiler/NFFrontEnd/NFExpandExp.mo

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,11 +761,14 @@ public
761761
input Operator op;
762762
output Expression outExp;
763763
output Boolean expanded;
764+
protected
765+
Operator scalar_op;
764766
algorithm
765767
(outExp, expanded) := expand(exp);
768+
scalar_op := Operator.scalarize(op);
766769

767770
if expanded then
768-
outExp := Expression.mapArrayElements(outExp, function makeUnaryOp(op = op));
771+
outExp := Expression.mapArrayElements(outExp, function makeUnaryOp(op = scalar_op));
769772
end if;
770773
end expandUnary;
771774

@@ -815,11 +818,14 @@ public
815818
input Operator op;
816819
output Expression outExp;
817820
output Boolean expanded;
821+
protected
822+
Operator scalar_op;
818823
algorithm
819824
(outExp, expanded) := expand(exp);
825+
scalar_op := Operator.scalarize(op);
820826

821827
if expanded then
822-
outExp := Expression.mapArrayElements(outExp, function makeLogicalUnaryOp(op = op));
828+
outExp := Expression.mapArrayElements(outExp, function makeLogicalUnaryOp(op = scalar_op));
823829
else
824830
outExp := exp;
825831
end if;

Compiler/NFFrontEnd/NFOperator.mo

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ public
195195
op.ty := ty;
196196
end setType;
197197

198+
function scalarize
199+
input output Operator op;
200+
algorithm
201+
op.ty := Type.arrayElementType(op.ty);
202+
end scalarize;
203+
198204
function symbol
199205
input Operator op;
200206
input String spacing = " ";

0 commit comments

Comments
 (0)