﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
2675	Issues when returning funref from function with multiple outputs	Per Östlund	Martin Sjölund	"Returning function references from a function which has multiple outputs causes some issues in the bootstrapped compiler:
{{{#!mo
encapsulated package P
  partial function PF
    input Real x;
    output Real y;
  end PF;

  function f
    input Real x;
    output Real y;
  algorithm
    y := x;
  end f;

  function f2
    input String s;
    output Real r;
    output PF pf;
  algorithm
    (r, pf) := match(s)
      case _ then (1.0, f);
    end match;
  end f2;

  function f3
    input String s;
    output Real r;
    output PF pf;
  algorithm
    (r, pf) := match(s)
      local PF lpf;
      // Avoid template error by returning the function indirectly.
      case _ equation lpf = f; then (1.0, lpf);
    end match;
  end f3;
end P;
}}}
Running this package through OpenModelica.Scripting.generateSeparateCode gives an error for f2:
{{{
[CodegenC.tpl:10056:14-10056:14:writable] Error: Template error: expTypeShort:#FUNCTION_REFERENCE_FUNC#.P.f<function>(Real x) => Real
}}}
Commenting out f2 makes generateSeparateCode succeed, but generated invalid code for f3. The issue is the second last line in the generated omc_P_f3 function:
{{{#!c
  if (outomc_pf) { *outomc_pf = (modelica_fnptr)omc_pf; }
}}}
The issue with this is simply that outomc_pf is not declared anywhere."	defect	closed	high	Bootstrapping	MetaModelica	trunk	fixed		
