#4635 closed defect (fixed)
Record fields types are not preserved for nested structures initialized without using Record constructor.
| Reported by: | Owned by: | Per Östlund | |
|---|---|---|---|
| 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 by , 8 years ago
| Component: | OMEdit → Frontend |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |
comment:2 by , 4 years ago
| Milestone: | Future → 1.18.0 |
|---|---|
| Resolution: | → fixed |
| Status: | assigned → closed |
comment:3 by , 4 years ago
| Milestone: | 1.18.0 → 1.19.0 |
|---|
Note:
See TracTickets
for help on using tickets.

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