Skip to content

Impredicative type-class context causes stack overflow or non-termination in type checker

This program makes GHC loop. The first time the stack overflows; the second time GHCi just hangs.

$ cat Bug.hs
{-# OPTIONS -fglasgow-exts #-}

module Bug where

data T t where
    T :: (forall a. T (f a)) -> T (forall a. f a)

instance Show (T t) where
    show (T t) = show t

$ ghci Bug.hs
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version 6.6, for Haskell 98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base ... linking ... done.
[1 of 1] Compiling Bug              ( Bug.hs, interpreted )
*** Exception: stack overflow
> :reload
[1 of 1] Compiling Bug              ( Bug.hs, interpreted )
Interrupted.
>
Trac metadata
Trac field Value
Version 6.6
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information