Opened 10 years ago

Closed 4 years ago

#2783 closed defect (fixed)

encapsulated model cannot find function

Reported by: Andreas Hofmann Owned by: Per Östlund
Priority: high Milestone: 1.16.0
Component: New Instantiation Version: trunk
Keywords: encapsulated Cc:

Description

Hi everyone!

Having a partial model which calls a function and is extended in an encapsulated model does not work. I'd be great if you guys could have a look.

Find attached a small example of the issue.

Best regards,
Andreas

Attachments (1)

TestEncapsulated.mo (1.5 KB ) - added by Andreas Hofmann 10 years ago.

Download all attachments as: .zip

Change History (4)

by Andreas Hofmann, 10 years ago

Attachment: TestEncapsulated.mo added

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

Owner: changed from somebody to Per Östlund
Status: newassigned

Smaller model:

package P

function f
  output Real r = 1.0;
end f;

model E
  Real r = f();
end E;

end P;

encapsulated model M
  import P.E;
  extends E;
end M;

comment:2 by Per Östlund, 10 years ago

This is the usual issue with how we incorrectly handle extends. Inherited elements are copied into the extending class, and paths are "fixed" by fully qualifying them. They are not marked as fully qualified though, so such "fixed" paths become restricted by encapsulation (and might not even point to the correct element anymore). Marking the paths as fully qualified does not work either though, since a fully qualified path does not always point to the same element as a non-qualified path (due to modifiers, etc.), which results in stack overflows for some models because the wrong element is used.

The solution is to rewrite the flattening of extends correctly. This is currently not possible though, since the Modelica specification does not specify how to flatten extends (see #1458 and #1397 on Modelica Trac). Hopefully this is resolved at the next design meeting (in december?), but until then I don't know what to do about this issue.

comment:3 by Per Östlund, 4 years ago

Component: FrontendNew Instantiation
Milestone: Future1.16.0
Resolution: fixed
Status: assignedclosed

Fixed in the new frontend.

Note: See TracTickets for help on using tickets.