﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3299	Array of records containing array get compilation errors when updated	Gustaf Thorslund	Mahder Alemseged Gebremedhin	"If putting arrays into records (to get some kind of abstraction), and then putting those records into an array, the generated code will fail to build due to unknown components in array.

{{{#!mo
loadString(""
package ArrayRecordArrayAssign
  record AR
    Integer a[2,3];
  end AR;
  
  function UpdateAR
    input AR ar;
    output AR result;
  algorithm
    result.a := 10*ar.a;
  end UpdateAR;

  function Test
    input Integer n;
    output AR result;
  protected
    AR a;
  algorithm
    for i in 1:n loop
      a := UpdateAR(a);
    end for;
    result := a;
  end Test;

  function Test2
    input Integer n;
    output AR[2] result;
  protected
    AR ara[2];
  algorithm
    for i in 1:n loop
      ara[1] := ara[2];
      ara[2] := UpdateAR(ara[2]);
    end for;
    result := ara;
  end Test2;
end ArrayRecordArrayAssign;
"");

// This works fine
x := ArrayRecordArrayAssign.Test(3);

// This gives compilation errors in generated code
y := ArrayRecordArrayAssign.Test2(3);
}}}

The assignment to a record works fine, but the assignment to a record within an array will fail.
{{{
Error: Error building simulator. Build log: gcc -I""/home/gustaf/src/openmodelica/build/include/omc/c""   -fPIC -O0 -falign-functions -march=native   -c -o ArrayRecordArrayAssign_Test2.o ArrayRecordArrayAssign_Test2.c
ArrayRecordArrayAssign_Test2.c: In function ‘omc_ArrayRecordArrayAssign_Test2’:
ArrayRecordArrayAssign_Test2.c:24:31: error: ‘ArrayRecordArrayAssign_AR_array’ has no member named ‘_a’
   alloc_integer_array(&_result._a, 2, 2, 3);alloc_generic_array(&_result, sizeof(ArrayRecordArrayAssign_AR), 1, (modelica_integer) 2);
                               ^
ArrayRecordArrayAssign_Test2.c:25:28: error: ‘ArrayRecordArrayAssign_AR_array’ has no member named ‘_a’
   alloc_integer_array(&_ara._a, 2, 2, 3);alloc_generic_array(&_ara, sizeof(ArrayRecordArrayAssign_AR), 1, (modelica_integer) 2);
.
.
.
}}}"	defect	accepted	high	Future	Code Generation	trunk		array, record	
