Opened 10 years ago

Closed 3 years ago

Last modified 3 years ago

#2802 closed defect (fixed)

Some issues with casting in constructor

Reported by: Vitalij Ruge Owned by: somebody
Priority: normal Milestone: 1.19.0
Component: Frontend Version: trunk
Keywords: Cc:

Description

Consider this example

package A
  operator record R
    Real x[n];
    parameter Integer n;

    encapsulated operator 'constructor'
      import A.R;

      function fromRealArray
        input Real x[n];
        input Integer n;
        output R result(x = x, n = n);
      algorithm

        annotation(Inline = true);
      end fromRealArray;
    end 'constructor';
  end R;

  model B
    R r = R(x = {1, 2}, n = 2);
    //R r = R(x = {1.0, 2}, n = 2); //work
  end B;
end A;

we get a "Type mismatch".

Change History (2)

comment:1 by Per Östlund, 3 years ago

Milestone: Future1.18.0
Resolution: fixed
Status: newclosed

The new frontend flattens the model correctly to:

class A.B
  Real r.x[1];
  Real r.x[2];
  final parameter Integer r.n = 2;
equation
  r.x = {1.0, 2.0};
end A.B;

comment:2 by Francesco Casella, 3 years ago

Milestone: 1.18.01.19.0
Note: See TracTickets for help on using tickets.