Opened 9 years ago

Closed 6 years ago

#3845 closed defect (fixed)

calling records to assign parameters fails if size is changed

Reported by: Michael Wetter Owned by: Per Östlund
Priority: high Milestone: 2.0.0
Component: New Instantiation Version:
Keywords: Cc:

Description

Hi

OpenModelica fails to flatten the model m1 unless the assignment of myRecord4 is removed.

package Test
 model m1
  parameter r myRecord1 = r(p={1});    // works
  parameter r myRecord2(p={1, 2});     // works
  parameter r myRecord3(p={3});        // works
  parameter r myRecord4 = r(p={1., 2.}); // fails
 end m1;
 record r
  parameter Real p[:] = {1};
 end r;
end Test;

The error is

Error: Type mismatch in binding myRecord4 = Test.r({1.0, 2.0}), expected subtype of record Test.r
  Real[2] p;
end Test.r;, got type record Test.r
  Real[1] p;
end Test.r;.
Error: Error occurred while flattening model Test.m1

This is the reason for
Buildings.HeatTransfer.Windows.Examples.ElectrochromicWindow
to fail, see https://test.openmodelica.org/libraries/Buildings/files/Buildings.HeatTransfer.Windows.Examples.ElectrochromicWindow.err

Change History (6)

comment:1 by Francesco Casella, 7 years ago

Milestone: Future2.0.0
Owner: changed from somebody to Per Östlund
Status: newassigned

@perost, can you make sure this works properly with the new front end?

comment:2 by Francesco Casella, 7 years ago

Component: *unknown*NF - New FrontEnd

comment:3 by Per Östlund, 7 years ago

Component: NF - New FrontEndNew Instantiation

Move all tickets from NF - New Frontend to New Instantiation so we don't have two different categories for the same thing.

comment:4 by Francesco Casella, 7 years ago

With the new front end, the flattened Test.m1 is

class Test.m1
  parameter Real myRecord1.p[1] = 1.0;
  parameter Real myRecord2.p[1] = 1.0;
  parameter Real myRecord2.p[2] = 2.0;
  parameter Real myRecord3.p[1] = 3.0;
  parameter Real myRecord4.p[1] = 1.0;
end Test.m1;

for some reason, the assignment myRecord4.p[2] = 2.0 is lost.

comment:5 by Francesco Casella, 6 years ago

With v1.13.0-dev-798-g1c8bb86de, the NF fails with

[Test: 9:3-9:28]: Failed to deduce dimension 1 of p due to missing binding equation.

which is better than a wrong result, but still needs fixing, particularly if it influences the Buildings library

comment:6 by Francesco Casella, 6 years ago

Resolution: fixed
Status: assignedclosed

As of v1.13.0-dev-1031-g06d58cd7f, the NF produces the correct result

Note: See TracTickets for help on using tickets.