Skip to content

Commit

Permalink
[NF] Fix some Expression.map*Opt functions.
Browse files Browse the repository at this point in the history
- Fix mapOpt, mapShallowOpt and mapFoldOpt in Expression, which would
  return an uninitialized value when given a NONE().
  • Loading branch information
perost committed Nov 13, 2019
1 parent b66d30c commit e9fc5e1
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions OMCompiler/Compiler/NFFrontEnd/NFExpression.mo
Expand Up @@ -1999,10 +1999,10 @@ public
protected
Expression e;
algorithm
if isSome(exp) then
SOME(e) := exp;
outExp := SOME(map(e, func));
end if;
outExp := match exp
case SOME(e) then SOME(map(e, func));
else exp;
end match;
end mapOpt;

function mapCall
Expand Down Expand Up @@ -2339,10 +2339,10 @@ public
protected
Expression e;
algorithm
if isSome(exp) then
SOME(e) := exp;
outExp := SOME(func(e));
end if;
outExp := match exp
case SOME(e) then SOME(func(e));
else exp;
end match;
end mapShallowOpt;

function mapCrefShallow
Expand Down Expand Up @@ -3271,11 +3271,15 @@ public
protected
Expression e;
algorithm
if isSome(exp) then
SOME(e) := exp;
(e, arg) := mapFold(e, func, arg);
outExp := SOME(e);
end if;
outExp := match exp
case SOME(e)
algorithm
(e, arg) := mapFold(e, func, arg);
then
SOME(e);

else exp;
end match;
end mapFoldOpt;

function mapFoldCall<ArgT>
Expand Down

0 comments on commit e9fc5e1

Please sign in to comment.