Opened 17 years ago

Closed 7 years ago

#132 closed defect (fixed)

Functions are not inherited correctly when extending packages

Reported by: Francesco Casella Owned by: Per Östlund
Priority: critical Milestone: 2.0.0
Component: New Instantiation Version:
Keywords: Cc: Francesco Casella, Adrian Pop

Description


Attachments (1)

TestPackageInheritance.mo (1.5 KB ) - added by Francesco Casella 17 years ago.
Modelica package with test cases

Download all attachments as: .zip

Change History (12)

by Francesco Casella, 17 years ago

Attachment: TestPackageInheritance.mo added

Modelica package with test cases

comment:1 by Francesco Casella, 17 years ago

Created an attachment (id=21)
Modelica package with test cases

When extending packages, the information about replaceable functions in the base class is not handled correctly.

When trying to simulate TestPackageInheritance.Test.Test_f, the following error is obtained:

Class MyPackage.f (its type) not found in scope TestPackageInheritance.Test.Test_f.

while MyPackage should inherit the definition of f from BasePackage

When trying to simulate TestPackageInheritance.Test.Test_h_wrong, the compiler should report an error, since the redeclaration of f in WrongPackage is illegal; conversely, OMC accept the declaration and allows to simulate the model.

comment:2 by Francesco Casella, 12 years ago

Component: Backend

I tried the test package with the scodeInstShortcut flag.

Test_f now works correctly

Test_g fails with: Error building simulator.

Test_h works correctly

Test_f_modified doesn't work correctly (y should be equal to -1, not to one)

Test_f_wrong should not compile (because WrongPackage.f is not compatible with BasePackage.f), but it actually compiles and run

comment:3 by Francesco Casella, 12 years ago

Component: BackendFrontend
Owner: changed from Francesco Casella to Adrian Pop
Status: newassigned

comment:4 by Adrian Pop, 12 years ago

Ok, I'll look into it.

comment:5 by Adrian Pop, 12 years ago

Partially fixed in r16060. We don't check for subtyping of redeclared elements yet.

in reply to:  5 comment:6 by Francesco Casella, 9 years ago

Replying to adrpo:

Partially fixed in r16060. We don't check for subtyping of redeclared elements yet.

Is this going to happen with the new flattening frontend?

comment:7 by Dietmar Winkler, 9 years ago

Milestone: Future

comment:8 by Francesco Casella, 8 years ago

Milestone: Future2.0.0

comment:9 by Francesco Casella, 7 years ago

Component: FrontendNew Instantiation

I guess the new FE should handle these cases correctly.

@perost, as you are currently working on redeclare, can you also try this test case?

comment:10 by Francesco Casella, 7 years ago

Owner: changed from Adrian Pop to Per Östlund

comment:11 by Francesco Casella, 7 years ago

Resolution: fixed
Status: assignedclosed

I ran the tests with -d=newInst using v1.13.0-dev-651-gd4122a2d8 (64-bit)

The first four tests work as expected and produce the correct result.

The last test should fail, because WrongPackage.f should be a subtype of BasePackage.f but it isn't. Unfortunately, OMC still does not detect this problem.

I opened #4901 on this specific issue.

Note: See TracTickets for help on using tickets.