Opened 4 years ago

Closed 4 years ago

#6221 closed defect (fixed)

The NF ignores a redeclare statement in a record containing a replaceable package and a function call from it

Reported by: Francesco Casella Owned by: Per Östlund
Priority: high Milestone: 1.18.0
Component: New Instantiation Version: 1.16.0
Keywords: Cc: Michael Wetter

Description (last modified by Francesco Casella)

Please check Buildings.Fluid.HeatExchangers.DXCoils.BaseClasses.Examples.NominalCondition. The NF complains that

[Buildings 7.0.0/Fluid/HeatExchangers/DXCoils/BaseClasses/NominalCondition.mo:36:3-40:32:writable] Error:
Medium is partial, name lookup is not allowed in partial classes.

This shouldn't be the case: the definition of record NominalCondition indeed calls functions from a partial package, but that package is redeclared to a non-partial one in the model being compiled.

I guess something goes wrong in the propagation of the redeclared type.

Change History (6)

comment:1 by Francesco Casella, 4 years ago

Resolution: fixed
Status: newclosed

Fixed in one of the commits reported here.

This also had a positive influence on other models in the testsuite, particularly within ModelicaTest.

comment:2 by Per Östlund, 4 years ago

Resolution: fixed
Status: closedreopened

Unfixed in PR 6946. The redeclare issue wasn't fixed, b2811ee relaxed the error checking a bit too much when instantiating record constructors.

comment:3 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

Retargeted to 1.18.0 because of 1.17.0 timed release.

comment:4 by Francesco Casella, 4 years ago

Description: modified (diff)

comment:5 by Francesco Casella, 4 years ago

Cc: Michael Wetter added

comment:6 by Per Östlund, 4 years ago

Resolution: fixed
Status: reopenedclosed

Fixed in d8f7882.

The issue was that the NominalCondition record contains a replaceable partial package that it uses functions from, and the package is then redeclared on the record instance. This means that the record constructor that's created from the record definition isn't really valid since it contains uses of a partial package, but in this case that's not an issue since the record constructor isn't used anyway.

For now I changed it so that the frontend allows the use of partial classes in record constructors, but ideally we should detect when a record constructor is invalid and give an error if it's used. But that would be quite hard to handle correctly.

Note: See TracTickets for help on using tickets.