Skip to content

Commit

Permalink
[NB] fix sample in algorithms (OpenModelica#12603)
Browse files Browse the repository at this point in the history
- correctly collect crefs in sample() calls in algorithms for partitioning and add layer of security with match
  • Loading branch information
kabdelhak committed Jun 18, 2024
1 parent dfa28cb commit 65c8813
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBPartitioning.mo
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,15 @@ protected
case "previous" then Expression.EMPTY(Type.INTEGER());
case "hold" then Expression.EMPTY(Type.INTEGER());
case "sample" algorithm
{_, _, arg} := Call.arguments(exp.call);
arg := match Call.arguments(exp.call)
// not collected samples have 2 arguments
case {_, arg} then arg;
// collected samples have 3 arguments
case {_, _, arg} then arg;
else algorithm
Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() + " failed for: " + Expression.toString(exp) + "."});
then fail();
end match;
_ := collectPartitioningCrefs(arg, var_crefs);
then Expression.EMPTY(Type.INTEGER());
else exp;
Expand Down

0 comments on commit 65c8813

Please sign in to comment.