Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix flattening of if-equations (#12373)
- Flatten the condition of an if-equation branch after evaluating it. Fixes #12368
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// name: IfEquation9 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
model A | ||
Real x; | ||
parameter Boolean b; | ||
equation | ||
if b then | ||
x = 2; | ||
else | ||
x = 3; | ||
end if; | ||
end A; | ||
|
||
model IfEquation9 | ||
parameter Boolean barr[6] = {false, false, true, false, true, false}; | ||
A a[4](b = barr[1:4]); | ||
end IfEquation9; | ||
|
||
// Result: | ||
// class IfEquation9 | ||
// parameter Boolean barr[1] = false; | ||
// parameter Boolean barr[2] = false; | ||
// parameter Boolean barr[3] = true; | ||
// parameter Boolean barr[4] = false; | ||
// parameter Boolean barr[5] = true; | ||
// parameter Boolean barr[6] = false; | ||
// Real a[1].x; | ||
// final parameter Boolean a[1].b = false; | ||
// Real a[2].x; | ||
// final parameter Boolean a[2].b = false; | ||
// Real a[3].x; | ||
// final parameter Boolean a[3].b = true; | ||
// Real a[4].x; | ||
// final parameter Boolean a[4].b = false; | ||
// equation | ||
// a[1].x = 3.0; | ||
// a[2].x = 3.0; | ||
// a[3].x = 2.0; | ||
// a[4].x = 3.0; | ||
// end IfEquation9; | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters