Opened 7 years ago

Closed 3 years ago

Last modified 3 years ago

#4635 closed defect (fixed)

Record fields types are not preserved for nested structures initialized without using Record constructor.

Reported by: jabozzo@… Owned by: perost
Priority: high Milestone: 1.19.0
Component: Frontend Version: v1.13.0-dev-nightly
Keywords: structure, record, nested Cc:

Description

In the folowing example:

package Example

  record A
    parameter Modelica.SIunits.Voltage param_a;
  end A;
  
  record B
    parameter A param_b;
  end B;
  
  constant A a0(param_a = 0);
  constant B b0(param_b = a0);
  
  constant A a1 = A(param_a = 0);
  constant B b1 = B(param_b = a1);
  
  model Bug
    parameter B params = b0;
  end Bug;
  
  model NormalA
    parameter A params = a0;
  end NormalA;
  
  model NormalB
    parameter B params = b1;
  end NormalB;
  
end Example;

Models NormalA and NormalB compile fine but Model Bug has the following error:

[1] 19:28:40 Translation Error
[Example: 18:5-18:28]: Type mismatch in binding param_b = Example.A$a0(0), expected subtype of record Example.A
  Real(quantity = "ElectricPotential", unit = "V") param_a;
end Example.A;, got type record Example.A$a0
  Integer param_a;
end Example.A$a0;.

Notice that constant a0's parameter, param_a. It's type has been changed to Integer, giving the mismatch, but this only occurs inside b0. A workaround can be using Record constructors, as in model NormalB. Sadly that workaround can't avoid bug #2365 .

Also, this bug may be related to #4623, since the nesting of the structures A and B is necesary for the bug, since NormalA can use a0 without problems.

Change History (3)

comment:1 Changed 7 years ago by adeas31

  • Component changed from OMEdit to Frontend
  • Owner changed from adeas31 to perost
  • Status changed from new to assigned

comment:2 Changed 3 years ago by perost

  • Milestone changed from Future to 1.18.0
  • Resolution set to fixed
  • Status changed from assigned to closed

Still broken in the old frontend, but works fine with the new frontend that's now the default.

comment:3 Changed 3 years ago by casella

  • Milestone changed from 1.18.0 to 1.19.0
Note: See TracTickets for help on using tickets.