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

Commit 20ca004

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
[NF] Fix evaluation of promote
We calculated the number of dimensions to promote, but did not pass this to the function. Belonging to [master]: - #2352
1 parent 38d78f5 commit 20ca004

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Compiler/NFFrontEnd/NFCeval.mo

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ algorithm
969969
Expression.INTEGER(n) := argN;
970970
ty := Expression.typeOf(arg);
971971
numToPromote := n - Type.dimensionCount(ty);
972-
result := evalBuiltinPromoteWork(arg, n);
972+
result := evalBuiltinPromoteWork(arg, numToPromote);
973973
end evalBuiltinPromote;
974974

975975
function evalBuiltinPromoteWork
@@ -981,7 +981,11 @@ protected
981981
list<Expression> exps;
982982
Type ty;
983983
algorithm
984-
Error.assertion(n >= 1, "Promote called with n<1", sourceInfo());
984+
Error.assertion(n >= 0, "Promote called with n<number of dimensions", sourceInfo());
985+
if n == 0 then
986+
result := arg;
987+
return;
988+
end if;
985989
if n == 1 then
986990
result := Expression.ARRAY(Type.liftArrayLeft(Expression.typeOf(arg),Dimension.fromInteger(1)), {arg});
987991
return;

0 commit comments

Comments
 (0)