Skip to content

Panic: collectNBinders

GHC 8.4.2 panics with the error message collectNBinders, when compiling with profiling. This is a very similar bug to #15002 (closed), but although #15002 (closed) is fixed in 8.4.2, this panic persists.

Steps to reproduce:

stack.yaml:

resolver: nightly-2018-04-30

bug.cabal:

name:                bug
version:             0.1.0.0
build-type:          Simple
cabal-version:       >=1.10

executable bug
  main-is:             Main.hs
  build-depends:       base
  default-language:    Haskell2010

Main.hs:

module Main where

main :: IO ()
main = do
  _ <- return $ getInt Circle
  return ()

newtype MyInt = MyInt Int

data Shape = Circle
           | Square

getInt :: Shape -> MyInt
getInt sh =
  case sh of
    Circle ->
        let (MyInt i) = MyInt 3
        in myInt i
    Square ->
        let (MyInt i) = MyInt 2
        in myInt i
    where
      myInt = MyInt

Then run:

$ stack ghc -- --version
The Glorious Glasgow Haskell Compilation System, version 8.4.2

$ stack build --profile
bug-0.1.0.0: configure (exe)
Configuring bug-0.1.0.0...
bug-0.1.0.0: build (exe)
Preprocessing executable 'bug' for bug-0.1.0.0..
Building executable 'bug' for bug-0.1.0.0..
[1 of 1] Compiling Main             ( Main.hs, .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.2.0.1/build/bug/bug-tmp/Main.p_o )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.4.2 for x86_64-unknown-linux):
	collectNBinders
  1
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
        pprPanic, called at compiler/coreSyn/CoreSyn.hs:2025:25 in ghc:CoreSyn

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


--  While building custom Setup.hs for package bug-0.1.0.0 using:
      /usr/local/home/cdisselk/.stack/setup-exe-cache/x86_64-linux-tinfo6-nopie/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.2 --builddir=.stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.2.0.1 build exe:bug --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
Edited by cdisselkoen
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information