#1797: type equality test leads to a looping type checker
-------------------------+--------------------------------------------------
    Reporter:  guest     |        Owner:         
        Type:  bug       |       Status:  new    
    Priority:  normal    |    Milestone:         
   Component:  Compiler  |      Version:  6.8    
    Severity:  normal    |   Resolution:         
    Keywords:            |   Difficulty:  Unknown
          Os:  Unknown   |     Testcase:         
Architecture:  x86       |  
-------------------------+--------------------------------------------------
Old description:

> The following code (similar to one of HList’s generic type equality
> tests) causes GHC to loop forever (or at least very long) with
> GHC 6.8.0.20071020 on i386-unknown-mingw32 and GHC 6.8.0.20071019 on i386
> -unknown-linux:
> {{{
> {-# LANGUAGE
>     MultiParamTypeClasses,
>     FunctionalDependencies,
>     UndecidableInstances,
>     OverlappingInstances,
>     FlexibleInstances,
>     EmptyDataDecls #-}
>
> data True
>
> data False
>
> class TypeEq type1 type2 result | type1 type2 -> result where
>     typeEq :: type1 -> type2 -> result
>
> instance TypeEq soleType soleType True where
>     typeEq _ _ = undefined
>
> instance (TypeCast False result) => TypeEq type1 type2 result where
>     typeEq _ _ = undefined
>
> class TypeCast type1 type2 | type1 -> type2, type2 -> type1
>
> instance TypeCast soleType soleType
> }}}

New description:

 The following code (similar to one of HList’s generic type equality tests)
 causes GHC to loop forever (or at least very long) with GHC 6.8.0.20071020
 on i386-unknown-mingw32 and GHC 6.8.0.20071019 on i386-unknown-linux:
 {{{
 {-# LANGUAGE
     MultiParamTypeClasses,
     FunctionalDependencies,
     UndecidableInstances,
     OverlappingInstances,
     FlexibleInstances,
     EmptyDataDecls #-}

 data True

 data False

 class TypeEq type1 type2 result | type1 type2 -> result where
     typeEq :: type1 -> type2 -> result

 instance TypeEq soleType soleType True where
     typeEq _ _ = undefined

 instance (TypeCast False result) => TypeEq type1 type2 result where
     typeEq _ _ = undefined

 class TypeCast type1 type2 | type1 -> type2, type2 -> type1

 instance TypeCast soleType soleType
 }}}

Comment (by simonpj):

 Definitely a bug; similar to #1795.

 Question: all instances of this bug seem to be for programs that should be
 rejected.  Are there any examples of divergence on programs that should be
 accepted?

 Meanwhile, will think about a fix.  I agree this is a serious regression.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1797#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to