Opened 15 years ago
Last modified 10 years ago
#1203 closed defect
Replaceable package behaves different when encapsulated in a package — at Initial Version
Reported by: | perob88 | Owned by: | perob88 |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Frontend | Version: | 1.5.0RC2 |
Keywords: | Cc: |
Description
Consider the following set of definitions. It is somewhat similar to the media library building blocks.
partial package partialStuff
constant Integer nz = 1;
end partialStuff;
package simpleStuff
extends testPackage.partialStuff(nz = 2);
end simpleStuff;
class modelComponent
replaceable package theStuff = testPackage.partialStuff;
Real compVar;
equation
compVar = theStuff.nz;
end modelComponent;
Now let's instatiate the following model
model myModel
package theStuff = simpleStuff;
modelComponent comp(redeclare package theStuff = theStuff);
end myModel;
This yields: OMC-ERROR: "Error: Class myModel.theStuff not found in scope modelComponent.theStuff.
Encapsulating everything inside another package:
package testPackage
...
...
...
...
end testPackage
followed by instantiateModel(testPackage.myModel) gives correct results.
A third variant where the only difference is another level of instantiation gives the wrong results but no compiler complaints...:
class myModel
replaceable package theStuff = partialStuff;
modelComponent comp(redeclare package theStuff = theStuff);
end myModel;
model myModel2
myModel modelInst(redeclare package theStuff = simpleStuff);
end myModel2;
instantiateModel(myModel2)
..
..
equation
modelInst.comp.compVar = 1.0;
Here the problem is that compVar should be 2.0 instead of 1.0