Opened 2 years ago

#5518 new defect

Constraining type for class used instead of component's too aggressively

Reported by: Jesper Mattsson Owned by: Jesper Mattsson
Priority: major Milestone:
Component: Modelica/FrontEnd Version: trunk
Keywords: Cc:


The type check for redeclares does not find errors due to wrong number of dimensions in some cases. This is because we try to look up the constraining type of the class for a component and use that, and then conclude that since the constraining type is a scalar class, then it is fine to redeclare to more dimensions. We should make sure that the reported constraining type has the correct size for the situation, and that we don't try to use the constraining type of the class in that manner when there are no replaceable classes involved.

Example that does not give an error about the redeclare:

model Test
    type T1 = Real;
    type T2 = Real[2];
    model A
        T1 x;
    end A;
    model C
        T2 x;
    end C;
    model F
        A a;
    end F;
    model G
        C a;
    end G;
    model H
        replaceable F f;
    end H;
    H h(redeclare G f);
end Test;

Change History (0)

Note: See TracTickets for help on using tickets.