Opened 10 years ago
Closed 6 years ago
#3183 closed defect (fixed)
Unknown dimensions during record construction
Reported by: | rfranke | Owned by: | somebody |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | Frontend | Version: | trunk |
Keywords: | Cc: |
Description
In case someone digs into the details of #3182, here is a related problem with the construction of records that contain arrays with dimensions determined by parameters of the records.
package UnknownSize record R parameter Integer nr; Real[nr] vr; end R; operator record S parameter Integer ns; Real[ns] vs; end S; function precalculation input R r; output S s(ns = r.nr); algorithm s.vs := 2*r.vr; end precalculation; model M1 "Translation error: Could not evaluate structural parameter (or constant): ns which gives dimensions of array: vs[ns]. Array dimensions must be known at compile time. " parameter R r(nr = 2, vr = {1, 2}); parameter S s = precalculation(r); end M1; model M2 "Translation error: Type mismatch for named argument in UnknownSize.R(vr={1, 2}). The argument has type: Integer[2] expected type: Real[nr] " parameter R r = R(nr = 2, vr = {1.0, 2.0}); parameter R r2 = R(nr = 2, vr = {1, 2}); parameter S s = precalculation(r); end M2; model M3 "Compilation error: UnknownSize.M3_06inz.c:54:31: error: use of undeclared identifier '$Ps$Pr$Pnr' $Ps$Pns = (modelica_integer)$Ps$Pr$Pnr; ^ " parameter R r(nr = 2, vr = {1, 2}); record S2 = S(ns = r.nr); parameter S2 s = precalculation(r); end M3; end UnknownSize;
UnknownSize.M1 fails to evaluate the structural parameter s.ns during flattening.
UnknownSize.M2 is able to calculate evaluate r.nr if a record constructor is used (instead of the arbitrary function precalculation). The record constructor fails to instantiate the Real array r2.vr with an Integer array though.
UnknownSize.M3 introduces S2 as a workaround to pass the frontend; afterwards it fails during compilation though.
Change History (8)
comment:1 Changed 9 years ago by sjoelund.se
- Milestone changed from 1.9.2 to 1.9.3
comment:2 Changed 9 years ago by sjoelund.se
- Milestone changed from 1.9.3 to 1.9.4
Moved to new milestone 1.9.4
comment:3 Changed 9 years ago by sjoelund.se
- Milestone changed from 1.9.4 to 1.9.5
Milestone pushed to 1.9.5
comment:4 Changed 9 years ago by sjoelund.se
- Milestone changed from 1.9.5 to 1.10.0
Milestone renamed
comment:5 Changed 8 years ago by sjoelund.se
- Milestone changed from 1.10.0 to 1.11.0
Ticket retargeted after milestone closed
comment:6 Changed 8 years ago by sjoelund.se
- Milestone changed from 1.11.0 to 1.12.0
Milestone moved to 1.12.0 due to 1.11.0 already being released.
comment:7 Changed 7 years ago by casella
- Milestone changed from 1.12.0 to Future
The milestone of this ticket has been reassigned to "Future".
If you think the issue is still valid and relevant for you, please select milestone 1.13.0 for back-end, code generation and run-time issues, or 2.0.0 for front-end issues.
If you are aware that the problem is no longer present, please select the milestone corresponding to the version of OMC you used to check that, and set the status to "worksforme".
In both cases, a short informative comment would be welcome.
comment:8 Changed 6 years ago by casella
- Resolution set to fixed
- Status changed from new to closed
The three reported test cases work fine with -d=newInst in version 1.13.0-dev.beta1
Milestone changed to 1.9.3 since 1.9.2 was released.