Opened 7 years ago

Last modified 7 years ago

#4905 assigned defect

Restriction on input connection is not enforced by OMC

Reported by: Francesco Casella Owned by: Per Östlund
Priority: high Milestone: 2.1.0
Component: New Instantiation Version:
Keywords: Cc:

Description

Please consider the following test package (also attached)

package TestProtectedConnector
  model M
    Modelica.Blocks.Interfaces.RealInput u if use_u;
    parameter Boolean use_u;
  // protected
    Modelica.Blocks.Interfaces.RealInput u_internal;
  equation
    if not use_u then
      u_internal = 1;
    end if;
    connect(u, u_internal);
  end M;

  model P
    TestProtectedConnector.M m1(use_u = true);
    TestProtectedConnector.M m2(use_u = false);
    Modelica.Blocks.Sources.RealExpression source;
  equation
    connect(source.y, m1.u);
  end P;
end TestProtectedConnector;

Model P is illegal, because it violates the rule stated in section 9.3 of the specification

A connection set of causal variables (input / output) may at most contain variables from one inside output connector or one public outside input connector.

With the old FE, a warning is issued

[TestProtectedConnector: 11:5-11:27]: 
Connecting two signal sources while connecting u to u_internal.

while the new FE silently accepts this code.

Other tools fail to compile the model, because it does not comply with the specification.

IMO this test case should generate an error also in OMC, accepting illegal Modelica code encourages bad modelling practices and hinders tool portability. We may add one flag to optionally lift this restriction, but it shouldn't be the default behaviour.

Attachments (1)

TestProtectedConnector.mo (550 bytes ) - added by Francesco Casella 7 years ago.

Download all attachments as: .zip

Change History (3)

by Francesco Casella, 7 years ago

Attachment: TestProtectedConnector.mo added

comment:1 by Francesco Casella, 7 years ago

Component: *unknown*New Instantiation
Milestone: Future2.0.0
Owner: changed from somebody to Per Östlund
Status: newassigned

comment:2 by Francesco Casella, 7 years ago

Milestone: 2.0.02.1.0

Rescheduled to the next milestone, as this kind of checks is less urgent than getting full coverage.

Note: See TracTickets for help on using tickets.