Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

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.

Re: Model Error with Packages

Hi,

I just got the latest version from SVN (r10585) and it gives the same error as before.

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.

Re: Model Error with Packages

Ok, this is now fixed in r10589. Thank you for reporting this.

There are 0 guests and 0 other users also viewing this topic