Opened 8 years ago

Closed 18 months ago

#2783 closed defect (fixed)

encapsulated model cannot find function

Reported by: AndreasHofmann Owned by: perost
Priority: high Milestone: 1.16.0
Component: New Instantiation Version: trunk
Keywords: encapsulated Cc:


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,

Attachments (1) (1.5 KB) - added by AndreasHofmann 8 years ago.

Download all attachments as: .zip

Change History (4)

Changed 8 years ago by AndreasHofmann

comment:1 Changed 8 years ago by

  • Owner changed from somebody to perost
  • Status changed from new to assigned

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 Changed 8 years ago by perost

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 Changed 18 months ago by perost

  • Component changed from Frontend to New Instantiation
  • Milestone changed from Future to 1.16.0
  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in the new frontend.

Note: See TracTickets for help on using tickets.