Opened 11 years ago

Closed 11 years ago

#2643 closed defect (fixed)

Generation of Equations from Record Default values not avoided if modification exist

Reported by: Jens Frenkel Owned by: somebody
Priority: blocker Milestone: 1.9.1
Component: Frontend Version: trunk
Keywords: Cc: Per Östlund, Lennart Ochel

Description

For the following model

model RecordDefaultValue

  record MyRecord
    Real a;
    Real b=24;
  end MyRecord;

  MyRecord r=MyRecord(time,-time);
end RecordDefaultValue;

omc generates the following flat model:

class RecordDefaultValue
  Real r.a;
  Real r.b = 24.0;
equation
  r.a = time;
  r.b = -time;
end RecordDefaultValue;

This is absolute wrong because the modification overwrites the default value from r.b.

Attachments (1)

RecordDefaultValue.mo (154 bytes ) - added by Jens Frenkel 11 years ago.

Download all attachments as: .zip

Change History (7)

by Jens Frenkel, 11 years ago

Attachment: RecordDefaultValue.mo added

comment:1 by Martin Sjölund, 11 years ago

Cc: Per Östlund added

comment:2 by Adrian Pop, 11 years ago

What omc does is correct as if the binding is not a scalar a structure copy should be performed. See 7.2.3 Merging of Modifications (the x5=x3 case).
The binding *always* has higher priority than the default values from the type.

comment:3 by Adrian Pop, 11 years ago

Or do you actually mean that r.b = 24 should not be present at all?
In that case I agree with you.

comment:4 by Lennart Ochel, 11 years ago

Cc: Lennart Ochel added

comment:5 by Jens Frenkel, 11 years ago

Yes, this is what I mean r.b = 24 should not be generated. Sorry for the imprecise description.

comment:6 by Per Östlund, 11 years ago

Resolution: fixed
Status: newclosed

Fixed in r19914.

Note: See TracTickets for help on using tickets.