Skip to content

Commit 5e4205a

Browse files
authored
[NB] fix if equation mapping (#10825)
- update else branch if it changed!
1 parent 1b5bf8e commit 5e4205a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

OMCompiler/Compiler/NBackEnd/Classes/NBEquation.mo

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,7 @@ public
20882088
input MapFuncExpWrapper mapFunc;
20892089
protected
20902090
Expression condition;
2091-
IfEquationBody else_if;
2091+
IfEquationBody else_if, old_else_if;
20922092
algorithm
20932093
condition := mapFunc(ifBody.condition, funcExp);
20942094
if not referenceEq(condition, ifBody.condition) then
@@ -2099,8 +2099,13 @@ public
20992099
ifBody.then_eqns := List.map(ifBody.then_eqns, function Pointer.apply(func = function Equation.map(funcExp = funcExp, funcCrefOpt = funcCrefOpt, mapFunc = mapFunc)));
21002100

21012101
if Util.isSome(ifBody.else_if) then
2102-
else_if := map(Util.getOption(ifBody.else_if), funcExp, funcCrefOpt, mapFunc);
2102+
old_else_if := Util.getOption(ifBody.else_if);
2103+
else_if := map(old_else_if, funcExp, funcCrefOpt, mapFunc);
2104+
if not referenceEq(else_if, old_else_if) then
2105+
ifBody.else_if := SOME(else_if);
2106+
end if;
21032107
end if;
2108+
21042109
end map;
21052110

21062111
function size

0 commit comments

Comments
 (0)