[GHC] #6117: Cyclic Type Class Hierarchy Produces <<loop>>

GHC cvs-ghc at haskell.org
Fri Oct 12 09:41:42 CEST 2012


#6117: Cyclic Type Class Hierarchy Produces <<loop>>
----------------------------------------+-----------------------------------
    Reporter:  jun0                     |       Owner:  simonpj                    
        Type:  bug                      |      Status:  new                        
    Priority:  normal                   |   Milestone:  7.8.1                      
   Component:  Compiler (Type checker)  |     Version:  7.4.1                      
    Keywords:                           |          Os:  Linux                      
Architecture:  Unknown/Multiple         |     Failure:  Incorrect result at runtime
  Difficulty:  Unknown                  |    Testcase:  T6117                      
   Blockedby:                           |    Blocking:                             
     Related:                           |  
----------------------------------------+-----------------------------------
Description changed by simonpj:

Old description:

> If there is a cyclic class hierarchy like
>
>     class B a => Semigroup a                  where ...[[BR]]
>     class Semigroup (Additive a) => Ring a    where ...[[BR]]
>     instance Ring a => Semigroup (Additive a) where ...[[BR]]
>
> then uses of B's methods on (Additive a) in the method implementations of
> the
> third declaration "instance Ring a => Semigroup (Additive a)" will:
>
>     1. be accepted by the compiler even in cases where B (Additive a) is
> not
>        derivable.
>     2. result in <<loop>>.
>
> The attached program prints <<loop>> when compiled with GHC-7.2.1 or
> newer but prints 1234567890 when compiled with GHC-7.0.4 or older.  I
> haven't had time to try out any revisions in between those two, but I did
> check that HEAD produces <<loop>> as well.

New description:

 If there is a cyclic class hierarchy like
 {{{
     class B a => Semigroup a                  where ...[[BR]]
     class Semigroup (Additive a) => Ring a    where ...[[BR]]
     instance Ring a => Semigroup (Additive a) where ...[[BR]]
 }}}
 then uses of B's methods on `(Additive a)` in the method implementations
 of the
 third declaration `instance Ring a => Semigroup (Additive a)` will:

     1. be accepted by the compiler even in cases where `B (Additive a)` is
 not derivable.
     2. result in <<loop>>.

 The attached program prints <<loop>> when compiled with GHC-7.2.1 or newer
 but prints 1234567890 when compiled with GHC-7.0.4 or older.  I haven't
 had time to try out any revisions in between those two, but I did check
 that HEAD produces <<loop>> as well.

--

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6117#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the Glasgow-haskell-bugs mailing list