Opened 6 years ago
Closed 5 years ago
#5225 closed defect (fixed)
Nested record assignments causes invalid code to be generated
Reported by: | Per Östlund | Owned by: | Mahder Alemseged Gebremedhin |
---|---|---|---|
Priority: | high | Milestone: | 1.16.0 |
Component: | Code Generation | Version: | v1.13.0-dev-nightly |
Keywords: | Cc: |
Description
Consider a model that contains nested record instance that's assigned in an algorithm section:
record R Real x; end R; record R2 Real y; R r; end R2; function f output R2 res = R2(1.0, R(2.0)); end f; model M R2 r2; algorithm r2 := f(); end M;
The assignment is compiled into a function M_eqFunction_2
, where r2
at the end of the function is assigned as:
data->localData[0]->realVars[1] /* r2.y variable */ = tmp2._y; $Pr2$Pr = tmp2._r;
The first assignment is correct, but the second fails to take into account that tmp2._r
is itself a record and tried to assign it to the non-existent variable $Pr2$Pr
.
This pattern is used in the HelmholtzMedia library, for example in HelmholtzMedia.Examples.Parameter.setSat_parameter (which only works with -d=newInst
, but this issue occurs also with the old frontend).
Change History (4)
comment:1 by , 6 years ago
comment:2 by , 5 years ago
Since this commit
https://github.com/OpenModelica/OpenModelica/commit/80ac1a491c0b0bc5c15e878636f0f0245295830d
most models are now compiling fine, and most also simulate, some fail during initialization:
https://libraries.openmodelica.org/branches/newInst/HelmholtzMedia/HelmholtzMedia.html
comment:3 by , 5 years ago
Milestone: | Future → 1.16.0 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:4 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I guess we can close this ticket.
Regarding the initialization issues, you may want to wait until #5770 is fixed.
Subscribing.
I believe the corresponding issue for the old frontend was issue #3089