Opened 5 years ago

Closed 4 years ago

#5225 closed defect (fixed)

Nested record assignments causes invalid code to be generated

Reported by: perost Owned by: mahge930
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 Changed 5 years ago by Matthis Thorade <matthis.thorade@…>

Subscribing.
I believe the corresponding issue for the old frontend was issue #3089

comment:2 Changed 4 years ago by matthis.thorade@…

comment:3 Changed 4 years ago by casella

  • Milestone changed from Future to 1.16.0
  • Owner changed from lochel to mahge930
  • Status changed from new to assigned

comment:4 Changed 4 years ago by casella

  • Resolution set to fixed
  • Status changed from assigned to closed

I guess we can close this ticket.

Regarding the initialization issues, you may want to wait until #5770 is fixed.

Note: See TracTickets for help on using tickets.