﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3280	Strange things happening when size of array in a record depends on a value in a constant record of the same record	Gustaf Thorslund	somebody	"When flattening the following model M, strange things are happening with array sizes.

{{{#!mo
package RecordArraySizeFromConstant
  record Range
    Real first = 0.0;
    Real last = 0.0;
    Integer n = 0;
  end Range;

  record RecIntegerIndex
    constant Range r[3];
    Real x[r[1].n,r[2].n,r[3].n];
  end RecIntegerIndex;

  type EnumIndex = enumeration (x1, x2, x3);

  record RecEnumIndex
    constant Range r[EnumIndex];
    Real x[r[EnumIndex.x1].n, r[EnumIndex.x2].n, r[EnumIndex.x3].n];
  end RecEnumIndex;

  model M
    RecIntegerIndex ri(r.n={2,3,5}, x(each start=0, each fixed=true));
    RecEnumIndex re(r.n={2,3,5}, x(each start=0, each fixed=true));
    RecIntegerIndex ri10(r.n={10,1,1}, x(each start=0, each fixed=true));
    RecEnumIndex re10(r.n={10,1,1}, x(each start=0, each fixed=true));

  algorithm
    when sample(0, 0.1) then
      ri.x := ri.x * 10;
      re.x := re.x * 10;
      ri10.x := ri10.x * 10;
      re10.x := re10.x * 10;
    end when;
  end M;
end RecordArraySizeFromConstant;
}}}

Just looking at '''ri''' it get the '''constant Range r''' set correctly, but the size depending on '''r''' appears to just become a mess:
{{{#!mo
class RecordArraySizeFromConstant.M
  constant Real ri.r[1].first = 0.0;
  constant Real ri.r[1].last = 0.0;
  constant Integer ri.r[1].n = 2;
  constant Real ri.r[2].first = 0.0;
  constant Real ri.r[2].last = 0.0;
  constant Integer ri.r[2].n = 3;
  constant Real ri.r[3].first = 0.0;
  constant Real ri.r[3].last = 0.0;
  constant Integer ri.r[3].n = 5;
  Real ri.x[1,1,1](start = 0.0, fixed = true);
  Real ri.x[1,1,2](start = 0.0, fixed = true);
  Real ri.x[1,2,1](start = 0.0, fixed = true);
  Real ri.x[1,2,2](start = 0.0, fixed = true);
  Real ri.x[2,1,1](start = 0.0, fixed = true);
  Real ri.x[2,1,2](start = 0.0, fixed = true);
  Real ri.x[2,2,1](start = 0.0, fixed = true);
  Real ri.x[2,2,2](start = 0.0, fixed = true);
// all of ri
}}}

'''re''' results in an array of size 5*5*5, '''ri10''' 10*10*10, and finally '''re10''' 1*1*1.

I'll attach the full output too. I built OMC using r25516 earlier today."	defect	closed	high	1.16.0	New Instantiation	trunk	fixed	array, constant, record	Mahder Alemseged Gebremedhin Adrian Pop Per Östlund
