﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
2849	"Wrong flattening of ""inner outer output"""	Bernhard Thiele	Adrian Pop	"
In the following model (also attached) the inner variable `v` declared in model `Test` is assigned to in model `B` where it is declared as `outer output`. `B` is instantiated in `A` and `A` is instantiated in `Test`. In model `A` variable `v` is declared as `inner outer output`. 

{{{#!mo
package Bug

  model B
    outer output Real v;
  equation
    v = time;
  end B;

  model A
    inner outer output Real v;
    Real y2;
    B b;
  equation
    y2 = v;
  end A;

  model Test
    inner Real v;
    Real y1;
    A a;
  equation
    y1 = v;
  end Test;
  
end Bug;
}}}

The model flattens, but the generated system of equations is wrong (therefore, it doesn't simulate). The flattened Modelica is:
{{{
class Bug.Test
  Real v;
  Real y1;
  Real a.v;
  Real a.y2;
equation
  a.v = time;
  a.y2 = v;
  y1 = v;
end Bug.Test;
}}}
Note that the equality constraint between `v` and `a.v` is lost.

Adding an additional constraint, e.g., `Real a.v = v` would make the flattened code valid. Alternatively, `a.v` could be substituted by `v` everywhere.
"	defect	accepted	high	Future	Frontend	trunk		inner outer	Adrian Pop
