Opened 9 years ago

Closed 4 years ago

#3833 closed defect (fixed)

Redeclaring package Medium = Medium in extends does not work

Reported by: Adrian Pop Owned by: Adrian Pop
Priority: high Milestone: 1.16.0
Component: New Instantiation Version:
Keywords: Cc:

Description

Reported here:
http://stackoverflow.com/questions/36228614/why-does-redeclare-package-medium-medium-not-work-when-extending-from-dynamicp/36229835?noredirect=1

The model:

within MyClass;

model Mypipe
  extends Modelica.Fluid.Pipes.DynamicPipe(redeclare package Medium = Medium);
  replaceable package Medium=Modelica.Media.Water.StandardWater;
equation
  annotation(Icon(coordinateSystem(grid = {2, 8})));
end Mypipe;

goes into an infinite loop during instantiation.

Change History (4)

comment:1 by Adrian Pop, 9 years ago

Owner: changed from somebody to Adrian Pop
Status: newaccepted

comment:2 by Christoph Buchner <buchner@…>, 5 years ago

Using 1.14.0-dev.beta1, I get two errors for this model (without the within MyClass;)

[1] 08:11:54 Translation Error
[test: 2:54-2:77]: Recursive short class definition of Medium in terms of Medium.

[2] 08:11:54 Translation Error
[Modelica.Fluid.Interfaces: 20:5-21:69]: Class Medium.ExtraProperty not found in scope FluidPort.

At least there's no infinite loop anymore.

comment:3 by Francesco Casella, 5 years ago

I'm sorry but I don't understand why you write the Mypipe model this way.

DynamicPipe already contains the declaration of a Medium package. Mypipe extends from it, so it already has it, and this causes some kind of conflict if you re-add the declaration with the same name. I can't see the point of doing so. Can't you just write

model Mypipe
  extends Modelica.Fluid.Pipes.DynamicPipe(   
    redeclare replaceable package Medium = Modelica.Media.Water.StandardWater);
  annotation(Icon(coordinateSystem(grid = {2, 8})));
end Mypipe;
Last edited 5 years ago by Francesco Casella (previous) (diff)

comment:4 by Per Östlund, 4 years ago

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

Closing this as fixed since the model is wrong and the new frontend as mentioned gives an error for it.

Note: See TracTickets for help on using tickets.