Skip to content

Instantly share code, notes, and snippets.

@msakai
Last active July 7, 2024 16:20
Show Gist options
  • Save msakai/01802d70e6752524c7d0a286a49cc135 to your computer and use it in GitHub Desktop.
Save msakai/01802d70e6752524c7d0a286a49cc135 to your computer and use it in GitHub Desktop.
GHC 9.6.6 fails with lookupIdSubst panic

GHC 9.6.6 fails with lookupIdSubst panic

https://gitlab.haskell.org/ghc/ghc/-/issues/25064

When I tried to compile the Bug.hs (which actually contains type errors) using GHC 9.6.6 and Stackage LTS 22.28, GHC panics with lookupIdSubst:

% stack build
bug> configure (lib)
Configuring bug-0.1.0.0...
bug> build (lib) with ghc-9.6.6
Preprocessing library for bug-0.1.0.0..
Building library for bug-0.1.0.0..
[1 of 1] Compiling Bug

<no location info>: error:
    panic! (the 'impossible' happened)
  GHC version 9.6.6:
	lookupIdSubst
  $dPrimMonad_a1Ft
  InScope {m_a1pT a_a1pU $dPrimMonad_a1pV table getNext nodeSymbol
           newRule g h}
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/GHC/Utils/Panic.hs:189:37 in ghc:GHC.Utils.Panic
        pprPanic, called at compiler/GHC/Core/Subst.hs:197:17 in ghc:GHC.Core.Subst
  CallStack (from HasCallStack):
    panic, called at compiler/GHC/Utils/Error.hs:454:29 in ghc:GHC.Utils.Error


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


Error: [S-7282]
       Stack failed to execute the build plan.
       
       While executing the build plan, Stack encountered the error:
       
       [S-7011]
       While building package bug-0.1.0.0 (scroll up to its section to see the error) using:
       /Users/sakai/.stack/setup-exe-cache/aarch64-osx/Cabal-simple_HwdwpEmb_3.10.3.0_ghc-9.6.6 --verbose=1 --builddir=.stack-work/dist/aarch64-osx/ghc-9.6.6 build lib:bug --ghc-options ""
       Process exited with code: ExitFailure 1 
cabal-version: 1.12
name: bug
version: 0.1.0.0
build-type: Simple
library
exposed-modules:
Bug
hs-source-dirs:
./
build-depends:
base >=4.7 && <5
, hashtables
, primitive
default-language: Haskell2010
module Bug where
import Control.Monad.Primitive
import qualified Data.HashTable.ST.Basic as H
data Symbol a = Symbol
data Node s a = Node
data Rule s a = Rule (Node s a)
data S s a
= S
{ table :: H.HashTable s (Symbol a, Symbol a) (Node s a)
}
getNext :: PrimMonad m => Node (PrimState m) a -> m (Node (PrimState m) a)
getNext = undefined
nodeSymbol :: Node s a -> Symbol a
nodeSymbol = undefined
newRule :: PrimMonad m => S (PrimState m) a -> (Symbol a, Symbol a) -> m (Rule (PrimState m) a)
newRule = undefined
f :: PrimMonad m => S (PrimState m) a -> Node (PrimState m) a -> m ()
f s n1 = do
n2 <- getNext n1
let x = (nodeSymbol n1, nodeSymbol n2)
ret <- stToPrim $ H.lookup (table s) x
case ret of
Nothing -> return ()
Just n1' -> do
n2' <- getNext n1'
ret <- g n1' n2'
case ret of
Just _ -> return ()
Nothing -> do
rule <- newRule x
h s n1 rule
return ()
g :: PrimMonad m => S (PrimState m) a -> Node (PrimState m) a -> Node (PrimState m) a -> m (Maybe (Rule (PrimState m) a))
g = undefined
h :: PrimMonad m => S (PrimState m) a -> Node (PrimState m) a -> Rule (PrimState m) a -> m ()
h = undefined
import Distribution.Simple
main = defaultMain
resolver:
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/28.yaml
packages:
- .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment