Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve subscripting of if-expressions (#8396)
- If the branches of an if-expression can't be subscripted because they have different dimensions, just subscript the whole if-expression instead. Fixes #8341
- Loading branch information
Showing
3 changed files
with
46 additions
and
5 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,26 @@ | ||
// name: IfExpression13 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
record R | ||
constant Boolean cond = false; | ||
constant Real[3] a = if cond then {1.0} else {1.0, 2.0, 3.0}; | ||
constant Real[2] b = a[1:end-1]; | ||
end R; | ||
|
||
model IfExpression13 | ||
R r = R(); | ||
end IfExpression13; | ||
|
||
// Result: | ||
// class IfExpression13 | ||
// constant Boolean r.cond = false; | ||
// constant Real r.a[1] = 1.0; | ||
// constant Real r.a[2] = 2.0; | ||
// constant Real r.a[3] = 3.0; | ||
// constant Real r.b[1] = 1.0; | ||
// constant Real r.b[2] = 2.0; | ||
// end IfExpression13; | ||
// 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