﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
1822	Replaceable type cannot unify with itself	adabe588@…	somebody	"This code looks okay to me, but the typechecker disagrees. I'm making a recursive call which causes a type unification error. I have similar code in other places that do not have this issue.

Actual Output:
{{{
{true,true,true}
true
""""

""[test.mo:17:3-17:27:writable] Error: Type mismatch in assignment in result := Collection.find(next, it) of polymorphic<Element> := polymorphic<$.Collection.Next.Element>
[test.mo:17:3-17:27:writable] Error: Type mismatch in pattern result
actual type:
  polymorphic<Element>
expected type:
  polymorphic<$.Collection.Next.Element>
""
}}}

Expected Output:
{{{
{true,true,true}
true
""""

(infinite loop)
}}}

Script:
{{{
setCommandLineOptions({""+d=rml,noevalfunc,failtrace"",""+g=MetaModelica"",""+showAnnotations""});

loadFile(""test.mo"");
getErrorString();

Test.test({1,2,3,4});
getErrorString();
}}}

Code:
{{{
encapsulated package Collection

replaceable type State subtypeof Any;
replaceable type Element subtypeof Any;

partial function Next
  input State state;
  output Element current;
  output State nextState;
end Next;

function find
  input Next next;
  input State it;
  output Element result;
algorithm
  result := find(next, it);
end find;

end Collection;


encapsulated package Test

protected import Collection.{find,Next};

public function firstRest<A>
  input List<A> list;
  output A first;
  output List<A> rest;
algorithm
  (first,rest) := match (list)
    case first :: rest then (first, rest);
 end match;
end firstRest;

function lfind<A>
  input Next next;
  input List<A> list;
  output A result;
algorithm
  result := find(firstRest, list);
end lfind;

function test
  input List<Integer> list;
  output Integer res;
algorithm
  res := lfind(firstRest, list);
end test;

end Test;
}}}
"	defect	new	high	Future	Backend	trunk		typechecking	
