id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os,architecture,failure,difficulty,testcase,blockedby,blocking,related
4358,infinite loop on unification with a type family context,patrick_premont,,"The following throws ghc (and ghci) in a loop (ghc-7.0.0.20100925 for i386-unknown-mingw32)
and it eventually aborts with ""ghc.exe: out of memory"".

{{{

> {-# LANGUAGE TypeFamilies, Rank2Types, FlexibleContexts #-}

> type family T a

> t2 :: forall a. ((T a ~ a) => a) -> a
> t2 = t
  
> t :: forall a. ((T a ~ a) => a) -> a
> t = undefined

}}}

Using ghc 6.12.1 we do not get a loop, but a puzzling error:

typeBug.lhs:9:7:
    Couldn't match expected type `(T a ~ a) => a'
           against inferred type `(T a ~ a) => a'
      Expected type: (T a ~ a) => a
      Inferred type: (T a ~ a) => a
    In the expression: t
    In the definition of `t2': t2 = t

I presume that the non-injectivity of type family T triggers the problem however
the following produces no errors in either version of the compiler.

{{{

> ok2 :: forall a. T a -> a
> ok2 = ok
  
> ok :: forall a. T a -> a
> ok = undefined

}}}",bug,closed,normal,,Compiler (Type checker),7.1,fixed,infinite loop type family context,,Windows,x86_64 (amd64),Compile-time crash,,indexed-types/should_compile/T4358,,,
