Skip to content

GADTs with newtype deriving can crash GHCi / cause Core Lint to fail

In my attempts to prove that GHC was generating errors on valid code, I have stumbled on a way to crash six versions of GHC, both F and FC, and in one case passing Core Lint!

stefan@stefans:/tmp$ V=6.4.2 ; ghc-$V -V ; ghc-$V -e 'seq icA ()' A.hs ; ghc-$V -dcore-lint -e 'seq icA ()' A.hs
The Glorious Glasgow Haskell Compilation System, version 6.4.2
*** Exception: Segmentation fault
*** Exception: Segmentation fault
stefan@stefans:/tmp$ V=6.6 ; ghc-$V -V ; ghc-$V -e 'seq icA ()' A.hs ; ghc-$V -dcore-lint -e 'seq icA ()' A.hs
The Glorious Glasgow Haskell Compilation System, version 6.6
mkCase1: null alts tpl_X6{v} [lid] main:A.icA{v rFP} [gid]
Segmentation fault
mkCase1: null alts tpl_X6{v} [lid] main:A.icA{v rFP} [gid]
ghc-6.6: panic! (the 'impossible' happened)
  (GHC version 6.6 for i386-unknown-linux):
        compileExpr
    <no location info>:
        In the expression: base:GHC.Err.error{(w) v 06} [gid]
                             @ base:GHC.Base.(){(w) tc 40} "Impossible alternative"
        Argument value doesn't match argument type:
        Fun type:
            [base:GHC.Base.Char{(w) tc 3o}] -> base:GHC.Base.(){(w) tc 40}
        Arg type: base:GHC.Prim.Addr#{(w) tc 33}
        Arg: "Impossible alternative"

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

stefan@stefans:/tmp$ V=6.7 ; ghc-$V -V ; ghc-$V -e 'seq icA ()' A.hs ; ghc-$V -dcore-lint -e 'seq icA ()' A.hs
The Glorious Glasgow Haskell Compilation System, version 6.7
mkCase1: null alts tpl_B1{v} [lid] main:A.icA{v rq2} [gid]
Segmentation fault
mkCase1: null alts tpl_B1{v} [lid] main:A.icA{v rq2} [gid]
ghc-6.7: panic! (the 'impossible' happened)
  (GHC version 6.7 for i386-unknown-linux):
        compileExpr
    <no location info>:
        In the expression: base:GHC.Err.error{(w) v 06} [gid]
                             @ base:GHC.Base.(){(w) tc 40} "Impossible alternative"
        Argument value doesn't match argument type:
        Fun type:
            [base:GHC.Base.Char{(w) tc 3o}] -> base:GHC.Base.(){(w) tc 40}
        Arg type: base:GHC.Prim.Addr#{(w) tc 33}
        Arg: "Impossible alternative"

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

stefan@stefans:/tmp$ V=6.7.20070213 ; ghc-$V -V ; ghc-$V -e 'seq icA ()' A.hs ; ghc-$V -dcore-lint -e 'seq icA ()' A.hs
The Glorious Glasgow Haskell Compilation System, version 6.7.20070213
mkCase: null alts tpl_B1{v} [lid] main:A.icA{v rsd} [gid]
Segmentation fault
mkCase: null alts tpl_B1{v} [lid] main:A.icA{v rsd} [gid]
ghc-6.7.20070213: panic! (the 'impossible' happened)
  (GHC version 6.7.20070213 for i386-unknown-linux):
        compileExpr
    <no location info>:
        In the expression: base:GHC.Err.error{(w) v 06} [gid]
                             @ base:GHC.Base.(){(w) tc 40} "Impossible alternative"
        Argument value doesn't match argument type:
        Fun type:
            [base:GHC.Base.Char{(w) tc 3o}] -> base:GHC.Base.(){(w) tc 40}
        Arg type: base:GHC.Prim.Addr#{(w) tc 33}
        Arg: "Impossible alternative"

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

stefan@stefans:/tmp$ V=6.7.20070223 ; ghc-$V -V ; ghc-$V -e 'seq icA ()' A.hs ; ghc-$V -dcore-lint -e 'seq icA ()' A.hs
The Glorious Glasgow Haskell Compilation System, version 6.7.20070223
mkCase: null alts tpl_B1{v} [lid] main:A.icA{v rs9} [gid]
Segmentation fault
mkCase: null alts tpl_B1{v} [lid] main:A.icA{v rs9} [gid]
ghc-6.7.20070223: panic! (the 'impossible' happened)
  (GHC version 6.7.20070223 for i386-unknown-linux):
        compileExpr
    <no location info>:
        In the expression: base:GHC.Err.error{(w) v 06} [gid]
                             @ base:GHC.Base.(){(w) tc 40} "Impossible alternative"
        Argument value doesn't match argument type:
        Fun type:
            [base:GHC.Base.Char{(w) tc 3o}] -> base:GHC.Base.(){(w) tc 40}
        Arg type: base:GHC.Prim.Addr#{(w) tc 33}
        Arg: "Impossible alternative"

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

stefan@stefans:/tmp$ V=6.7.20070323 ; ghc-$V -V ; ghc-$V -e 'seq icA ()' A.hs ; ghc-$V -dcore-lint -e 'seq icA ()' A.hs
The Glorious Glasgow Haskell Compilation System, version 6.7.20070323
mkCase: null alts tpl_B1{v} [lid] main:A.icA{v rs4} [gid]
Segmentation fault
mkCase: null alts tpl_B1{v} [lid] main:A.icA{v rs4} [gid]
ghc-6.7.20070323: panic! (the 'impossible' happened)
  (GHC version 6.7.20070323 for i386-unknown-linux):
        compileExpr
    <no location info>:
        In the expression: base:GHC.Err.error{(w) v 06} [gid]
                             @ base:GHC.Base.(){(w) tc 40} "Impossible alternative"
        Argument value doesn't match argument type:
        Fun type:
            [base:GHC.Base.Char{(w) tc 3o}] -> base:GHC.Base.(){(w) tc 40}
        Arg type: base:GHC.Prim.Addr#{(w) tc 33}
        Arg: "Impossible alternative"

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

stefan@stefans:/tmp$ cat A.hs
{-# OPTIONS_GHC -fglasgow-exts #-}
module A(II(..), icA) where

data II a where II :: II Int

class IC a where ic :: II a

instance IC Int where ic = II

newtype A = A Int deriving(IC)

icA = (ic :: II A)
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
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information