Opened 6 years ago

Closed 5 years ago

# Size of array in record depending on param in record

Reported by: Owned by: Jesper Mattsson Jonathan Kämpe major 1.15 Modelica/FrontEnd trunk

### Description

When the size on an array in a record is determined by a parameter in the same record, and the parameter gets its value from the binding expression of the record instance, then the size becomes 0.

Example:

```model Test
record A
parameter Integer n;
Real x[n];
end A;

function f
input Integer n;
output A a(n=n);
algorithm
a.x := 1:n;
end f;

parameter Integer m = 2;
parameter A a = f(m);
Real y[m] = a.x;
end Test;
```

### comment:1 Changed 6 years ago by Jonathan Kämpe

Summary: Size of array in record derending on param in record → Size of array in record depending on param in record

### comment:2 Changed 6 years ago by Jesper Mattsson

Milestone: Pending → 1.14.x

### comment:3 Changed 6 years ago by Jesper Mattsson

Status: new → accepted

### comment:4 Changed 6 years ago by Jesper Mattsson

Milestone: 1.14.x → Pending

Fixed handling of size of array in record depending on parameter in record for simple cases.

Cases that still aren't handled:

```model Test1
record A
parameter Integer n;
Real x[n];
end A;

function f
input Integer n;
output A a(n=n);
algorithm
a.x := 1:n;
end f;

parameter Integer m = 2;
A a[m] = f(1:m);
Real y[m] = a[2].x;
end Test1;

model Test2
record A
parameter Integer n;
Real x[n];
end A;

record B
A a;
end B;

parameter Integer m = 2;
B b = B(A(m, 1:m));
Real y[m] = b.a.x;
end Test2;
```

### comment:5 Changed 6 years ago by Jesper Mattsson

Fixed tests broken by r6266.

### comment:6 Changed 6 years ago by Jesper Mattsson

Fixed evaluation of constants in records that was broken by r6279.

### comment:7 Changed 5 years ago by Jesper Mattsson

Owner: changed from Jesper Mattsson to Jonathan Kämpe accepted → assigned

### comment:8 Changed 5 years ago by Jonathan Kämpe

Some more test cases:

```model Test
record R
parameter Integer n = 1;
parameter Real x[n] =( 1:n);
end R;

R r1;
R r2(x={9});
R r3(n=2);
R r4(n=2, x={8,7});
end Test;

model Test2
record R
parameter Integer n;
parameter Real x[n] =( 1:n);
end R;

R r3(n=2);
R r4(n=2, x={8,7});
end Test2;

model Test3
record R
parameter Integer n = 1;
parameter Real x[n];
end R;

R r1;
R r2(x={9});
R r3(n=2);
R r4(n=2, x={8,7});
end Test3;

model Test4
record R
parameter Integer n;
parameter Real x[n];
end R;

R r3(n=2);
R r4(n=2, x={8,7});
end Test4;
```

### comment:9 Changed 5 years ago by Tove Bergdahl

Milestone: Pending → 1.15.x

### comment:10 Changed 5 years ago by Jonathan Kämpe

Scalarization of records with array size defined by modified component.

Introducing composite variabilities to preserve variability of mixed records until scalarization.

### comment:11 Changed 5 years ago by Jesper Mattsson

Milestone: 1.15.x → 1.15

Move remaining tickets to next milestone.

### comment:12 Changed 5 years ago by Jonathan Kämpe

Resolution: → fixed assigned → closed

This seems finished.

Note: See TracTickets for help on using tickets.