-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix evaluation of record fields (#12940)
- Delay the type matching when creating a binding for a record field from its parent during constant evaluation. The reason why it might not already have been type matched is usually that it's used in a dimension, in which case the parent might not yet have been completely typed.
- Loading branch information
Showing
4 changed files
with
103 additions
and
35 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
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
65 changes: 65 additions & 0 deletions
65
testsuite/flattening/modelica/scodeinst/RecordBinding14.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,65 @@ | ||
// name: RecordBinding14 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
package Cooling | ||
record DXCoil | ||
parameter Integer nSta = 1; | ||
parameter Stage sta[nSta]; | ||
end DXCoil; | ||
|
||
record NominalValues | ||
parameter Real TEvaIn_nominal = 292.55; | ||
parameter Real m_flow_nominal; | ||
end NominalValues; | ||
|
||
record Stage | ||
parameter NominalValues nomVal; | ||
end Stage; | ||
end Cooling; | ||
|
||
package Heating | ||
model DryCoil | ||
parameter Cooling.DXCoil datCoi; | ||
end DryCoil; | ||
|
||
model SingleSpeed | ||
parameter DXCoil datCoi; | ||
DryCoil dxCoi(final datCoi = datCoi); | ||
end SingleSpeed; | ||
|
||
record DXCoil | ||
parameter Integer nSta = 1; | ||
parameter Stage sta[nSta]; | ||
end DXCoil; | ||
|
||
record NominalValues | ||
parameter Real m_flow_nominal; | ||
parameter Real TEvaIn_nominal = 292.55; | ||
end NominalValues; | ||
|
||
record Stage | ||
parameter NominalValues nomVal; | ||
end Stage; | ||
end Heating; | ||
|
||
model RecordBinding14 | ||
parameter Heating.DXCoil datCoi(sta = {Heating.Stage(nomVal = Heating.NominalValues(m_flow_nominal = 2))}); | ||
Heating.SingleSpeed sinSpeDX(final datCoi = datCoi); | ||
end RecordBinding14; | ||
|
||
// Result: | ||
// class RecordBinding14 | ||
// final parameter Integer datCoi.nSta = 1; | ||
// parameter Real datCoi.sta[1].nomVal.m_flow_nominal = 2.0; | ||
// parameter Real datCoi.sta[1].nomVal.TEvaIn_nominal = 292.55; | ||
// final parameter Integer sinSpeDX.datCoi.nSta = 1; | ||
// final parameter Real sinSpeDX.datCoi.sta[1].nomVal.m_flow_nominal = datCoi.sta[1].nomVal.m_flow_nominal; | ||
// final parameter Real sinSpeDX.datCoi.sta[1].nomVal.TEvaIn_nominal = datCoi.sta[1].nomVal.TEvaIn_nominal; | ||
// final parameter Integer sinSpeDX.dxCoi.datCoi.nSta = 1; | ||
// final parameter Real sinSpeDX.dxCoi.datCoi.sta[1].nomVal.TEvaIn_nominal = 292.55; | ||
// final parameter Real sinSpeDX.dxCoi.datCoi.sta[1].nomVal.m_flow_nominal = 2.0; | ||
// end RecordBinding14; | ||
// endResult |