Skip to content

Panic! (the "impossible" happened) bug in GHC 8.2.1 rc2

The following causes a panic in GHC 8.2.1 rc2:

module Main where

indexOr :: a -> Int -> [a] -> a
indexOr fallback idx xs =
  if (idx < length xs)
  then xs !! idx
  else fallback

main :: IO ()
main = undefined

When compiling I get:

    [1 of 1] Compiling Main             ( src/Examples/table-sort.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.0.0/build/fltkhs-table-sort/fltkhs-table-sort-tmp/Main.o )
    ghc: panic! (the 'impossible' happened)
      (GHC version 8.2.0.20170507 for x86_64-unknown-linux):
    	idInfo
      a_a2ws
      Call stack:
          CallStack (from HasCallStack):
            prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1134:58 in ghc:Outputable
            callStackDoc, called at compiler/utils/Outputable.hs:1138:37 in ghc:Outputable
            pprPanic, called at compiler/basicTypes/Var.hs:526:34 in ghc:Var
    
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
Edited by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information