- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Model Error with Packages
Model Error with Packages
Model Error with Packages
Code:
package Lib
package TypePackage
type Type = Real;
end TypePackage;
model PackageModel
replaceable package Pack = TypePackage;
Pack.Type v;
equation
v = 1;
end PackageModel;
end Lib;
model Test
package Pack = Lib.TypePackage;
Lib.PackageModel mod1(redeclare package Pack = Pack); // Gives error
Lib.PackageModel mod2(redeclare package Pack = Lib.TypePackage); // Works
equation
end Test;
Calling checkModel(Test) results in the following error:
[test.mo:19:35-19:54:writable] Error: Class .Test.Pack not found in scope Lib.PackageModel.Pack.
[test.mo:9:3-9:14:writable] Error: Class Pack.Type not found in scope Lib.PackageModel while instantiating mod1.v.
Error: Error occurred while flattening model Test
It seems that the redeclaration in PackageModel is converted to:
Code:
model PackageModel
PackageModel.Pack = .Test.Pack;
...
end PackageModel;
instead of what I expected to be:
Code:
model PackageModel
PackageModel.Pack = Lib.TypePackage;
...
end PackageModel;
Is this the correct behaviour and how can I achieve what I was intenting?
Best regards,
Michael
Re: Model Error with Packages
Hi Michael,
This bug was solved some time ago, so if you update to the latest release of OpenModelica it should work as intended.
- perost
- 114 Posts
Re: Model Error with Packages
Ok, I only tested instantiation of the model and assumed that it worked. But it seems like there's some problem with checking it. I will look into the problem.
- perost
- 114 Posts
Re: Model Error with Packages
Ok, this is now fixed in r10589. Thank you for reporting this.
- perost
- 114 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Model Error with Packages