Skip to content

Commit

Permalink
Fix check of when branches (#9742)
Browse files Browse the repository at this point in the history
- `reinit` should not be considered an assignment when checking for
  assigned variables in `when` branches.

Fixes #9738
  • Loading branch information
perost committed Nov 23, 2022
1 parent e3fb1bd commit 5c06585
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
1 change: 0 additions & 1 deletion OMCompiler/Compiler/NFFrontEnd/NFVerifyModel.mo
Expand Up @@ -159,7 +159,6 @@ protected
crefs := match eq
case Equation.EQUALITY() then whenEquationEqualityCrefs(eq.lhs, crefs);
case Equation.ARRAY_EQUALITY() then whenEquationEqualityCrefs(eq.lhs, crefs);
case Equation.REINIT() then whenEquationEqualityCrefs(eq.cref, crefs);
case Equation.IF() then whenEquationIfCrefs(eq.branches, eq.source, crefs);
else crefs;
end match;
Expand Down
18 changes: 8 additions & 10 deletions testsuite/flattening/modelica/scodeinst/When7.mo
@@ -1,6 +1,6 @@
// name: When7
// keywords:
// status: correct
// status: incorrect
// cflags: -d=newInst
//
//
Expand All @@ -16,13 +16,11 @@ equation
end When7;

// Result:
// class When7
// Real x;
// equation
// when time > 0.0 then
// x = 1.0;
// elsewhen time > 1.0 then
// reinit(x, 2.0);
// end when;
// end When7;
// Error processing file: When7.mo
// [flattening/modelica/scodeinst/When7.mo:11:3-15:11:writable] Error: The same variables must be solved in elsewhen clause as in the when clause.
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
//
// Execution failed!
// endResult

0 comments on commit 5c06585

Please sign in to comment.