Changes between Initial Version and Version 1 of Ticket #1203
- Timestamp:
- 2015-03-18T15:04:13Z (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #1203
- Property Cc removed
- Property Component → Frontend
- Property Resolution → fixed
- Property Status new → closed
-
TabularUnified Ticket #1203 – Description
initial v1 1 1 Consider the following set of definitions. It is somewhat similar to the media library building blocks. 2 {{{#!mo 3 partial package partialStuff 4 constant Integer nz = 1; 5 end partialStuff; 6 7 package simpleStuff 8 extends testPackage.partialStuff(nz = 2); 9 end simpleStuff; 10 11 class modelComponent 12 replaceable package theStuff = testPackage.partialStuff; 13 Real compVar; 14 equation 15 compVar = theStuff.nz; 16 end modelComponent; 17 }}} 18 Now let's instatiate the following model 19 {{{#!mo 20 model myModel 21 package theStuff = simpleStuff; 22 modelComponent comp(redeclare package theStuff = theStuff); 23 end myModel; 24 }}} 25 This yields: OMC-ERROR: "Error: Class myModel.theStuff not found in scope modelComponent.theStuff. 2 26 3 partial package partialStuff \\ 4 constant Integer nz = 1; \\ 5 end partialStuff; \\ 6 \\ 7 package simpleStuff \\ 8 extends testPackage.partialStuff(nz = 2); \\ 9 end simpleStuff; \\ 10 \\ 11 class modelComponent \\ 12 replaceable package theStuff = testPackage.partialStuff; \\ 13 Real compVar; \\ 14 equation \\ 15 compVar = theStuff.nz; \\ 16 end modelComponent; \\ 17 \\ 18 Now let's instatiate the following model 27 Encapsulating everything inside another package: 28 {{{#!mo 29 package testPackage 30 ... 31 ... 32 ... 33 ... 34 end testPackage 35 }}} 36 followed by instantiateModel(testPackage.myModel) gives correct results. 19 37 20 model myModel \\ 21 package theStuff = simpleStuff; \\ 22 modelComponent comp(redeclare package theStuff = theStuff); \\ 38 A third variant where the only difference is another level of instantiation gives the wrong results but no compiler complaints...: 39 {{{#!mo 40 class myModel 41 replaceable package theStuff = partialStuff; 42 modelComponent comp(redeclare package theStuff = theStuff); 23 43 end myModel; 24 44 25 This yields: OMC-ERROR: "Error: Class myModel.theStuff not found in scope modelComponent.theStuff. \\ 26 \\ 27 Encapsulating everything inside another package: \\ 28 package testPackage \\ 29 ... \\ 30 ... \\ 31 ... \\ 32 ... \\ 33 end testPackage \\ 34 \\ 35 followed by instantiateModel(testPackage.myModel) gives correct results. 36 \\ 37 \\ 38 A third variant where the only difference is another level of instantiation gives the wrong results but no compiler complaints...: \\ 45 model myModel2 46 myModel modelInst(redeclare package theStuff = simpleStuff); 47 end myModel2; 39 48 40 41 class myModel \\ 42 replaceable package theStuff = partialStuff; \\ 43 modelComponent comp(redeclare package theStuff = theStuff); \\ 44 end myModel; 45 46 model myModel2 \\ 47 myModel modelInst(redeclare package theStuff = simpleStuff); \\ 48 end myModel2; \\ 49 \\ 50 instantiateModel(myModel2) \\ 51 .. \\ 52 .. \\ 53 equation \\ 54 modelInst.comp.compVar = 1.0; \\ 55 \\ 56 \\ 49 instantiateModel(myModel2) 50 .. 51 .. 52 equation 53 modelInst.comp.compVar = 1.0; 54 }}} 57 55 Here the problem is that compVar should be 2.0 instead of 1.0