Skip to content

GHC panic with defer-typed-holes

Does this still happen in HEAD?

import qualified GHC.Generics as GHC
import Generics.SOP
import Generics.SOP.TH
import Data.Proxy

gminbound' :: (Generic a, Code a ~ (xs:xss), All2 Bounded (Code a)) => a
gminbound' = minBound
  & I
  & hcpure (Proxy @Bounded)
  & apInjs_POP
  & head
  & to

Fails but doesn't crash with

$ ghci -ignore-dot-ghci -XTypeApplications -XTypeOperators -XDataKinds -XGADTs -XFlexibleContexts /tmp/tX96.hs 
GHCi, version 8.0.1: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( /tmp/tX96.hs, interpreted )

/tmp/tX96.hs:8:3: error:
    Variable not in scope: (&) :: t4 -> (a0 -> I a0) -> t3

/tmp/tX96.hs:9:3: error:
    Variable not in scope: (&) :: t3 -> t5 -> t2

/tmp/tX96.hs:10:3: error:
    Variable not in scope:
      (&) :: t2 -> (POP f1 xss0 -> [SOP f1 xss0]) -> t1

/tmp/tX96.hs:11:3: error:
    Variable not in scope: (&) :: t1 -> ([a1] -> a1) -> t0

/tmp/tX96.hs:12:3: error:
    Variable not in scope: (&) :: t0 -> (Rep a2 -> a2) -> a
Failed, modules loaded: none.
Prelude> 

but crashes with -fdefer-typed-holes

$ ghci -ignore-dot-ghci -fdefer-typed-holes -XTypeApplications -XTypeOperators -XDataKinds -XGADTs -XFlexibleContexts /tmp/tX96.hs 
GHCi, version 8.0.1: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( /tmp/tX96.hs, interpreted )

/tmp/tX96.hs:8:3: warning: [-Wtyped-holes]
    Variable not in scope: (&) :: t4 -> (a0 -> I a0) -> t3

/tmp/tX96.hs:9:3: warning: [-Wtyped-holes]
    Variable not in scope: (&) :: t3 -> t5 -> t2

/tmp/tX96.hs:10:3: warning: [-Wtyped-holes]
    Variable not in scope:
      (&) :: t2 -> (POP f1 xss0 -> [SOP f1 xss0]) -> t1

/tmp/tX96.hs:11:3: warning: [-Wtyped-holes]
    Variable not in scope: (&) :: t1 -> ([a1] -> a1) -> t0

/tmp/tX96.hs:12:3: warning: [-Wtyped-holes]
    Variable not in scope: (&) :: t0 -> (Rep a2 -> a2) -> a
ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.1 for x86_64-unknown-linux):
        opt_univ fell into a hole {aabX}

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

> 

More minimal example, still requires generics-sop:

import Generics.SOP

a = minBound
  & hcpure (Proxy @Bounded)
Trac metadata
Trac field Value
Version 8.0.1
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