Opened 12 years ago

Closed 4 years ago

Last modified 4 years ago

#1934 closed defect (fixed)

Support calling functions via component reference

Reported by: Christian Schubert Owned by: Adrian Pop
Priority: high Milestone: 1.14.0
Component: Frontend Version: trunk
Keywords: replaceable partial function Cc: Martin Sjölund

Description

Hi,

while testing several Hydraulics libraries I encountered the following problem with OpenModelica:

We have a partial record which defines a partial replaceable function. In a subclass the function is redeclared with a proper implementation.

This record is then used in as an inner/outer variable where the outer variable is defined as the baseclass and the inner variable is the proper subclass.

Unfortunately OpenModelica tries to compile the partial function from the inner baseclass and thus the model becomes invalid.

In the simplified submodel attached there seems to be also a problem with lookup which does not occur in dymola?!

This technique is found in several different libraries, so I use priority = High.

Background:
For every fluid there is a record specifying a function for calculating the bulk modulus. We have a single BaseClass for all fluids defining which functions have to be implemented. All library components then use 'outer BaseClass' in their implementations hoping that they use the proper inner model from the top model.

Attachments (2)

Bug.mos (69 bytes ) - added by anonymous 12 years ago.
Bug.mo (986 bytes ) - added by anonymous 12 years ago.

Download all attachments as: .zip

Change History (17)

by anonymous, 12 years ago

Attachment: Bug.mos added

by anonymous, 12 years ago

Attachment: Bug.mo added

comment:1 by mikaelf@…, 12 years ago

This defect is related to the newly clarified section of the MSL specification about the combination of outer with a partial model. https://trac.modelica.org/Modelica/ticket/1074

Currently omc returns an error for illegal instantiation of a partial class in this very simple example, which should now be allowed.

package test
  partial model Base
  end Base;
  model Model
    outer Base base;
  end Model;
end test;

comment:2 by Adrian Pop, 12 years ago

mikaelf, the reported bug has nothing to do with the outer with a partial type.
Your example will work *if* you specify a inner which is not partial.
If you don't specify any inner then the outer type will be used/instantiated and of course you will run into issues because is partial!

comment:3 by Adrian Pop, 12 years ago

Hm, this bug has mostly to do with calling a function via a component reference.
I'll see what I can do.

comment:4 by Martin Sjölund, 12 years ago

Status: newassigned
Summary: replaceable partial functionSupport calling functions via component reference

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

Milestone: 1.9.01.9.1

Postponed until 1.9.1

comment:6 by Martin Sjölund, 10 years ago

Milestone: 1.9.11.9.2

This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).

comment:7 by Martin Sjölund, 10 years ago

Milestone: 1.9.21.9.3

Milestone changed to 1.9.3 since 1.9.2 was released.

comment:8 by Martin Sjölund, 9 years ago

Milestone: 1.9.31.9.4

Moved to new milestone 1.9.4

comment:9 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.5

Milestone pushed to 1.9.5

comment:10 by Martin Sjölund, 9 years ago

Milestone: 1.9.51.10.0

Milestone renamed

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

Milestone: 1.10.01.11.0

Ticket retargeted after milestone closed

comment:12 by Martin Sjölund, 8 years ago

Milestone: 1.11.01.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:13 by Francesco Casella, 7 years ago

Milestone: 1.12.0Future

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:14 by Per Östlund, 4 years ago

Resolution: fixed
Status: assignedclosed

This seems to have been fixed some time ago, it now seems to work fine with both the old and the new frontend.

comment:15 by Francesco Casella, 4 years ago

Milestone: Future1.14.0
Note: See TracTickets for help on using tickets.