Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle empty arrays better during unit checking (#10064)
- Check for zero-dimensions instead of using `Expression.isEmptyArray` when checking if a unit expression is a non-empty array, since an array can be non-empty and still not contain any scalar elements (such as `{{}}`). - Avoid having to evaluate `fill` calls when getting the unit string from an expression, all elements in the resulting array will be the same anyway so we can just take the fill argument directly instead. Fixes #10057
- Loading branch information
Showing
4 changed files
with
38 additions
and
7 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
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,24 @@ | ||
// name: UnitCheck23 | ||
// keywords: initialization | ||
// status: correct | ||
// cflags: -d=newInst --unitChecking -d=dumpUnits | ||
|
||
loadString(" | ||
model UnitCheck23 | ||
type MassFlowRate = Real(final unit = \"kg/s\"); | ||
MassFlowRate[1, 0] ports_mXi_flow; | ||
end UnitCheck23; | ||
"); getErrorString(); | ||
|
||
instantiateModel(UnitCheck23); getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// (ports_mXi_flow, 1000.0 * s^(-1) * g^(1)) | ||
// ######## UnitCheck COMPLETED ######## | ||
// "class UnitCheck23 | ||
// end UnitCheck23; | ||
// " | ||
// "" | ||
// endResult |