From 5c06585e2061c4065e3917627b324eb26fbdd589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=96stlund?= Date: Wed, 23 Nov 2022 14:29:06 +0100 Subject: [PATCH] Fix check of when branches (#9742) - `reinit` should not be considered an assignment when checking for assigned variables in `when` branches. Fixes #9738 --- .../Compiler/NFFrontEnd/NFVerifyModel.mo | 1 - .../flattening/modelica/scodeinst/When7.mo | 18 ++++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/OMCompiler/Compiler/NFFrontEnd/NFVerifyModel.mo b/OMCompiler/Compiler/NFFrontEnd/NFVerifyModel.mo index ccf29e06fa2..285fa42ff65 100644 --- a/OMCompiler/Compiler/NFFrontEnd/NFVerifyModel.mo +++ b/OMCompiler/Compiler/NFFrontEnd/NFVerifyModel.mo @@ -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; diff --git a/testsuite/flattening/modelica/scodeinst/When7.mo b/testsuite/flattening/modelica/scodeinst/When7.mo index 0bb937d582e..602b8fcfaea 100644 --- a/testsuite/flattening/modelica/scodeinst/When7.mo +++ b/testsuite/flattening/modelica/scodeinst/When7.mo @@ -1,6 +1,6 @@ // name: When7 // keywords: -// status: correct +// status: incorrect // cflags: -d=newInst // // @@ -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