#1795: typechecker loops on simple program with fundep
-------------------------+--------------------------------------------------
    Reporter:  guest     |        Owner:  simonpj
        Type:  bug       |       Status:  new    
    Priority:  normal    |    Milestone:  6.8.1  
   Component:  Compiler  |      Version:  6.8    
    Severity:  major     |   Resolution:         
    Keywords:            |   Difficulty:  Unknown
          Os:  Multiple  |     Testcase:  yes    
Architecture:  x86       |  
-------------------------+--------------------------------------------------
Old description:

> The program below causes the "Renamer/typechecker" phase to loop.
> Confirmed with GHC 6.8.20070927 on Linux and 6.9.20071018 on Windows (so
> I'm not absolutely certain it's present in latest 6.8, but it seems very
> likely).
>
> The program has an infinite type - the definition of translate causes
> (String, a) to be unified with a. Removing the fundep in MkA causes a
> reasonable error to be reported.
>
> {{{
> {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies,
> FlexibleInstances #-}
> module X() where
>
> data A a = A
>
> class MkA a b | a -> b where
>    mkA :: a -> A b
>
> instance MkA a a where
>
> translate :: (String, a) -> A a
> translate a = mkA a
> }}}
>
> Ganesh

New description:

 The program below causes the "Renamer/typechecker" phase to loop.
 Confirmed with GHC 6.8.20070927 on Linux and 6.9.20071018 on Windows (so
 I'm not absolutely certain it's present in latest 6.8, but it seems very
 likely).

 The program has an infinite type - the definition of translate causes
 (String, a) to be unified with a. Removing the fundep in MkA causes a
 reasonable error to be reported.

 {{{
 {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies,
 FlexibleInstances #-}
 module X() where

 data A a = A

 class MkA a b | a -> b where
    mkA :: a -> A b

 instance MkA a a where

 translate :: (String, a) -> A a
 translate a = mkA a
 }}}

 Ganesh

 PS: See also #1797 and #1781

Comment (by simonpj):

 Definitely a bug. It happens because the improvement gives rise to an
 equality `(a ~ (String,a))`, and this equality is simply generated but not
 discharged, by `TcSimplify.tcImprove`.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1795#comment:3>
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