Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't evaluate dims that refer to function inputs (#9023)
Fixes #9017
- Loading branch information
Showing
5 changed files
with
81 additions
and
1 deletion.
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
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
58 changes: 58 additions & 0 deletions
58
testsuite/flattening/modelica/scodeinst/FunctionRecordArg5.mo
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,58 @@ | ||
// name: FunctionRecordArg5 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
model FunctionRecordArg5 | ||
record BaseRecord | ||
constant Integer nx = 4; | ||
end BaseRecord; | ||
|
||
record ExtendRecord | ||
extends BaseRecord(nx=6); | ||
end ExtendRecord; | ||
|
||
function initArr | ||
input BaseRecord r = ExtendRecord(); | ||
output Real x_1; | ||
protected | ||
Real x[r.nx-1]; | ||
algorithm | ||
x := zeros(r.nx - 1); | ||
x_1 := x[1]; | ||
end initArr; | ||
|
||
BaseRecord r = ExtendRecord(); | ||
Real x_1; | ||
equation | ||
x_1 = initArr(r); | ||
end FunctionRecordArg5; | ||
|
||
// Result: | ||
// function FunctionRecordArg5.BaseRecord "Automatically generated record constructor for FunctionRecordArg5.BaseRecord" | ||
// input Integer nx = 4; | ||
// output BaseRecord res; | ||
// end FunctionRecordArg5.BaseRecord; | ||
// | ||
// function FunctionRecordArg5.ExtendRecord "Automatically generated record constructor for FunctionRecordArg5.ExtendRecord" | ||
// input Integer nx = 6; | ||
// output ExtendRecord res; | ||
// end FunctionRecordArg5.ExtendRecord; | ||
// | ||
// function FunctionRecordArg5.initArr | ||
// input FunctionRecordArg5.BaseRecord r = FunctionRecordArg5.ExtendRecord(6); | ||
// output Real x_1; | ||
// protected Real[r.nx - 1] x; | ||
// algorithm | ||
// x := fill(0.0, r.nx - 1); | ||
// x_1 := x[1]; | ||
// end FunctionRecordArg5.initArr; | ||
// | ||
// class FunctionRecordArg5 | ||
// constant Integer r.nx = 6; | ||
// Real x_1; | ||
// equation | ||
// x_1 = FunctionRecordArg5.initArr(r); | ||
// end FunctionRecordArg5; | ||
// 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