﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3411	Compiler does not detect unassigned variable in some cases with if equations	Adrian Pop	Martin Sjölund	"The compiler does not detect that b3 is not assigned and because of that the behavior is undefined and random. See also [changeset:92eaf4/OMCompiler]

{{{
#!mo
protected function inlineWhenEq
  ""inlines function calls in when equations""
  input BackendDAE.WhenEquation inWhenEquation;
  input Inline.Functiontuple fns;
  input DAE.ElementSource inSource;
  output BackendDAE.WhenEquation outWhenEquation;
  output DAE.ElementSource outSource;
  output Boolean inlined;
algorithm
  (outWhenEquation,outSource,inlined) := matchcontinue(inWhenEquation)
    local
      DAE.ComponentRef cref;
      DAE.Exp e,e_1,cond;
      BackendDAE.WhenEquation weq,weq_1;
      DAE.ElementSource source;
      Boolean b1,b2,b3;
      list<DAE.Statement> assrtLst;
      BackendDAE.WhenEquation we, elsewe;
      Option<BackendDAE.WhenEquation> oelsewe;
      list<BackendDAE.WhenOperator> whenStmtLst;

    case BackendDAE.WHEN_STMTS(condition=cond, whenStmtLst=whenStmtLst, elsewhenPart = oelsewe)
      equation
        (cond, source, b1,_) = Inline.inlineExp(cond, fns, inSource);
        (whenStmtLst, b2) = inlineWhenOps(whenStmtLst, fns);

        if isSome(oelsewe) then
          SOME(elsewe) = oelsewe;
          (elsewe, source, b3) = inlineWhenEq(elsewe, fns, source);
          oelsewe = SOME(elsewe);
        else
          oelsewe = NONE();
          // the compiler does not detect that b3 is not assigned
          // b3 = false;
        end if;
      then (BackendDAE.WHEN_STMTS(cond, whenStmtLst, oelsewe), source, b1 or b2 or b3);

  end matchcontinue;
end inlineWhenEq;
}}}"	defect	new	high	Future	MetaModelica	trunk			Willi Braun
