#1909 closed defect (fixed)
Propagate redeclares correctly
Reported by: | Per Östlund | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | 1.9.4 |
Component: | New Instantiation | Version: | trunk |
Keywords: | Cc: |
Description
The new instantiation has issues when it comes to propagating redeclares, because it tries to fully qualify redeclares instead of looking them up in the correct environment. This means that models such as this doesn't work:
model A replaceable package Medium = PartialMedium; Medium.BaseProperties medium; end A; model B A a(redeclare package Medium = Medium); replaceable package Medium = PartialMedium; end B; model C B b(redeclare package Medium = NonPartialMedium); end C;
In this case it will use the old declaration of B.Medium when applying the redeclare to a. We need to look up B.Medium so that we get the redeclared declaration.
Change History (10)
follow-up: 2 comment:1 by , 12 years ago
comment:2 by , 12 years ago
Replying to adrpo:
Hi. Here is a more complex model that seems to have this issue.
It might be also that redeclares inside redeclare inside redeclare are not all applied.
I've actually already fixed this issue, I just put up the ticket to keep track of what I've done. But your model helped me find a stupid mistake in my code (using the wrong variable), so I guess it was a good idea to create a ticket :)
To my great surprise it actually seems like the redeclares are handled correctly in this model with my fixes, although there are some issues with the dependency analysis which removes Extends.X.z. I want to clean up the code and sprinkle some comments on it before I commit the fix though.
comment:3 by , 12 years ago
Sounds great.
Please push your changes in as soon as possible as I
really need them to test my translator on bigger models.
Cheers,
Adrian Pop/
comment:5 by , 12 years ago
Hi,
With the last version r15135 (probably since 1.9.0Beta4), I face the same problem (though it used to work before).
Actually, the version below works:
model A replaceable package Medium = PartialMedium; Medium.BaseProperties medium; end A; model B A a(redeclare package Medium = Medium); replaceable package Medium = PartialMedium; end B; model C B b(redeclare package Medium = NonPartialMedium); end C;
But if we change package names, it does not work anymore:
model A replaceable package MediumA = PartialMedium; MediumA.BaseProperties medium; end A; model B A a(redeclare package MediumA = MediumB); replaceable package MediumB = PartialMedium; end B; model C B b(redeclare package MediumB = NonPartialMedium); end C;
comment:7 by , 12 years ago
Replying to adrpo:
Have you tried with flag +d=scodeInstShortcut?
I just did. It works with this flag. What exactly does it mean? My model is not well written?
Best regards,
H.
comment:8 by , 12 years ago
No. Your model is correct.
The old instantiation cannot handle correctly all redeclares.
This flag uses new lookup together with the old instantiation.
It should work for any models that have redeclares and do not
work with the old instantiation.
I'm trying now to get rid of the flag by making it the default.
comment:9 by , 9 years ago
Milestone: | Future → pre1.9.4 |
---|
It doesn't make sense to keep closed ticket in the "Future" milestone that were simply forgotten to assign to the correct milestone in the past.
comment:10 by , 7 years ago
Milestone: | pre1.9.4 → 1.9.4 |
---|
Removing the pre1.9.4 milestone in favor of 1.9.4.
Hi. Here is a more complex model that seems to have this issue.
It might be also that redeclares inside redeclare inside redeclare are not all applied.