#2029 closed defect (fixed)
Incorrect cyclically dependent error, inheritance issue (from MathCore)
| Reported by: | Owned by: | probably noone | |
|---|---|---|---|
| Priority: | high | Milestone: | 1.16.0 |
| Component: | New Instantiation | Version: | trunk |
| Keywords: | Cc: |
Description
Problem with inheritance which induces a cyclically dependent constants or parameters error, if however the partial models are included in the model the example works.
package TestCyclic
model TestModel "Fails to flatten"
extends TestCyclic.Internal.SetDefinition;
TestCyclic.FlexModel flexModel1(doSomething = doMoreSpecific);
end TestModel;
model FlexModel
extends TestCyclic.Internal.Base;
TestCyclic.Internal.Shape shape1 if doMoreSpecific;
end FlexModel;
package Internal
partial model SetDefinition
parameter Boolean doSomething = true;
final parameter Boolean doMoreSpecific = doSomething and true and true;
end SetDefinition;
model Base
extends TestCyclic.Internal.SetDefinition;
TestCyclic.Internal.NullShape nullShape1 if not doMoreSpecific;
end Base;
model Shape
end Shape;
model NullShape
end NullShape;
end Internal;
Without extending partial models
// Do the same w/o using extends, which works.
model TestModel2 "Works, includes the code which is extended in TestModel"
parameter Boolean doSomething = true;
final parameter Boolean doMoreSpecific = doSomething and true and true;
TestCyclic.FlexModel2 flexModel1(doSomething = doMoreSpecific);
end TestModel2;
model FlexModel2 "Includes the code which is extended in FlexModel"
parameter Boolean doSomething = true;
final parameter Boolean doMoreSpecific = doSomething and true and true;
TestCyclic.Internal.NullShape nullShape1 if not doMoreSpecific;
TestCyclic.Internal.Shape shape1 if doMoreSpecific;
end FlexModel2;
end TestCyclic;
Change History (14)
comment:1 by , 13 years ago
| Component: | Backend → Frontend |
|---|---|
| Resolution: | → invalid |
| Status: | new → closed |
comment:2 by , 13 years ago
| Resolution: | invalid |
|---|---|
| Status: | closed → reopened |
I think you are wrong. When I do it manually i get this:
The original model:
package TestCyclic
model TestModel "Fails to flatten"
extends TestCyclic.Internal.SetDefinition;
TestCyclic.FlexModel flexModel1(doSomething = doMoreSpecific);
end TestModel;
model FlexModel
extends TestCyclic.Internal.Base;
TestCyclic.Internal.Shape shape1 if doMoreSpecific;
end FlexModel;
package Internal
partial model SetDefinition
parameter Boolean doSomething = true;
final parameter Boolean doMoreSpecific = doSomething and true and true;
end SetDefinition;
model Base
extends TestCyclic.Internal.SetDefinition;
TestCyclic.Internal.NullShape nullShape1 if not doMoreSpecific;
end Base;
model Shape
end Shape;
model NullShape
end NullShape;
end Internal;
end TestCyclic;
Removeflatten inheritance :
package TestCyclic
model TestModel "Fails to flatten"
parameter Boolean doSomething = true; //Inherited from SetDefinition
final parameter Boolean doMoreSpecific = doSomething and true and true; // Inherited from SetDefinition
TestCyclic.FlexModel flexModel1(doSomething = doMoreSpecific);
end TestModel;
model FlexModel
parameter Boolean doSomething = true; //Inherited from Base->SetDefinition
final parameter Boolean doMoreSpecific = doSomething and true and true; // Inherited from Base->SetDefinition
TestCyclic.Internal.NullShape nullShape1 if not doMoreSpecific; // Inherited from Base
TestCyclic.Internal.Shape shape1 if doMoreSpecific;
end FlexModel;
...
end Internal;
Flatten out flexModel1 in TestModel and apply modifiers:
model TestModel "Fails to flatten"
parameter Boolean doSomething = true;
final parameter Boolean doMoreSpecific = doSomething and true and true;
parameter Boolean flexModel1.doSomething = doMoreSpecific;
final parameter Boolean flexModel1.doMoreSpecific = flexModel1.doSomething and true and true;
TestCyclic.Internal.NullShape flexModel1.nullShape1 if not flexModel1.doMoreSpecific;
TestCyclic.Internal.Shape flexModel1.shape1 if flexModel1.doMoreSpecific;
end TestModel;
This doesn't result in a cyclic dependency. Maybe you got confused about the scoping rules of modifiers?
comment:3 by , 13 years ago
Yes, the damn scoping confused me :) Anyway, the new instantiation handles this correctly already...
$ omc a.mo +i=TestCyclic.TestModel +d=scodeInst /home/marsj/trunk/build/bin/omc 1.9.0 Beta2 (r14687) class TestModel parameter Boolean doSomething = true; parameter Boolean doMoreSpecific = true; parameter Boolean flexModel1.doSomething = true; parameter Boolean flexModel1.doMoreSpecific = true; end TestModel;
comment:5 by , 11 years ago
| Milestone: | 1.9.1 → 1.9.2 |
|---|
This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).
comment:6 by , 11 years ago
| Milestone: | 1.9.2 → 1.9.3 |
|---|
Milestone changed to 1.9.3 since 1.9.2 was released.
comment:11 by , 9 years ago
| Milestone: | 1.11.0 → 1.12.0 |
|---|
Milestone moved to 1.12.0 due to 1.11.0 already being released.
comment:12 by , 8 years ago
| Milestone: | 1.12.0 → Future |
|---|
The milestone of this ticket has been reassigned to "Future".
If you think the issue is still valid and relevant for you, please select milestone 1.13.0 for back-end, code generation and run-time issues, or 2.0.0 for front-end issues.
If you are aware that the problem is no longer present, please select the milestone corresponding to the version of OMC you used to check that, and set the status to "worksforme".
In both cases, a short informative comment would be welcome.
comment:13 by , 5 years ago
| Component: | Frontend → New Instantiation |
|---|---|
| Resolution: | → fixed |
| Status: | reopened → closed |
comment:14 by , 5 years ago
| Milestone: | Future → 1.16.0 |
|---|

In the first model you get
In the second model you get:
The first one should not work (give the error we do right now). The second should work. And after running omc, this is what we do.
Look at that model and you see that it is very easy to calculate each of the parameters by going top down.