﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5236	The backend should break down initial record equations into their scalar counterparts	Francesco Casella	Per Östlund	"Consider the following test model.
{{{
model M1
  record R
    Real x;
    Real y;
  end R;
  
  Real x;
  Real y;
equation
  R(3,4) = R(x,y);
end M1;
}}}
The new front-end flattens it to
{{{
function M1.R ""Automatically generated record constructor for M1.R""
  input Real x;
  input Real y;
  output R res;
end M1.R;

class M1
  Real x;
  Real y;
equation
  M1.R(3.0, 4.0) = M1.R(x, y);
end M1;
}}}
then the backend immediately breaks down the record = record equation into two scalar equations
{{{
######################################## 
pre-optimization module normalInlineFunction (simulation) 
######################################## 
 
 
unknown partition 
======================================== 
 
Variables (2) 
======================================== 
1: y:VARIABLE(flow=false )  type: Real  
2: x:VARIABLE(flow=false )  type: Real  
 
 
Equations (2, 2) 
======================================== 
1/1 (1): 4.0 = y   [dynamic |0|0|0|0|] 
2/2 (1): 3.0 = x   [dynamic |0|0|0|0|] 
}}}
Consider now this second test case, which has exactly the same structure but involves {{{fixed = false}}} parameters and initial equations instead
{{{
model M2
  record R
    Real x;
    Real y;
  end R;
  
  parameter Real x(fixed = false);
  parameter Real y(fixed = false);
initial equation
  R(3,4) = R(x,y);
end M2;
}}}
The new frontend flattens it in the same way as {{{M1}}} to
{{{
function M2.R ""Automatically generated record constructor for M2.R""
  input Real x;
  input Real y;
  output R res;
end M2.R;

class M2
  parameter Real x(fixed = false);
  parameter Real y(fixed = false);
initial equation
  M2.R(3.0, 4.0) = M2.R(x, y);
end M2;
}}}
However, the back-end does not break down the initial equation into its scalar counterparts, and carries the record equation through the whole optimization phase
{{{
Initial Equations (1, 2) 
======================================== 
1/1 (2): M2.R(3.0, 4.0) = M2.R(x, y)   [dynamic |0|0|0|0|] 
}}}
until eventually failing
{{{
Internal error complex equations currently only supported on form v = functioncall(...). Equation: M2.R(3.0, 4.0) = M2.R(x, y) solve for {y,x}
}}}
because nonlinear equations in the form record = record are not supported. 

The initial record equation should instead be broken into its scalar components at the beginning of the backend operation, in the same way as the regular equations.

Solving this issue should also fix #4354."	defect	closed	critical	1.13.0	New Instantiation		fixed		Per Östlund Willi Braun Adrian Pop
