GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2023-09-13T12:07:04Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/22684Panic with valid hole fits + unsatisiable constraint2023-09-13T12:07:04ZKrzysztof GogolewskiPanic with valid hole fits + unsatisiable constraintThis program causes a panic in 9.4 and master:
```haskell
{-# LANGUAGE DataKinds #-}
module M where
data F x
p :: forall r p. ((r ~ Just p) => F r) -> F r
p = undefined
q :: F Nothing
q = p _
```
```
panic! (the 'impossible' hap...This program causes a panic in 9.4 and master:
```haskell
{-# LANGUAGE DataKinds #-}
module M where
data F x
p :: forall r p. ((r ~ Just p) => F r) -> F r
p = undefined
q :: F Nothing
q = p _
```
```
panic! (the 'impossible' happened)
GHC version 9.4.3:
validHoleFits no evdest
[G] 'Nothing ~# 'Just p0_aKD[tau:1]
```
Alternatively:
```haskell
module M where
p :: (Int ~ Bool => r) -> r
p = undefined
q :: r
q = p _
```
Credits to Sjoerd Visscher for finding the issue.sheafsam.derbyshire@gmail.comsheafsam.derbyshire@gmail.comhttps://gitlab.haskell.org/ghc/ghc/-/issues/22662GHC panic with -O -fno-cpr-anal -fno-cse -fno-full-laziness2023-04-18T10:54:25ZMatthew NaylorGHC panic with -O -fno-cpr-anal -fno-cse -fno-full-laziness## Summary
Panic in GHC 9.4.3 when compiling 4-line program with `-O -fno-cpr-anal -fno-cse -fno-full-laziness`. No panic occurs on 9.2.5.
## Steps to reproduce
Put the following code in a file named `Bug.hs`
```
module Bug where
i...## Summary
Panic in GHC 9.4.3 when compiling 4-line program with `-O -fno-cpr-anal -fno-cse -fno-full-laziness`. No panic occurs on 9.2.5.
## Steps to reproduce
Put the following code in a file named `Bug.hs`
```
module Bug where
import Data.Set
foo x = sequence_ [ f y | y <- x ]
where f _ = return (fromList [0])
```
Now, on the command line:
```
$ ghc -O -fno-cpr-anal -fno-cse -fno-full-laziness Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.4.3:
completeCall
conrep_X1
Stop[BoringCtxt] Integer
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:182:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Opt/Simplify.hs:1911:9 in ghc:GHC.Core.Opt.Simplify
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
Removing any of the command-line flags seems to cause the panic to disappear.
## Expected behavior
Compile without a panic.
(Why the strange combination of flags? One of our larger source files takes a long time to compile unless cpr-anal is turned off. The other options are there for historic reasons and not really needed, but still I thought I'd report the bug in case in shows up in other ways.)
## Environment
* GHC version used: 9.4.3
Optional:
* Operating System: Linux
* System Architecture: x86_64https://gitlab.haskell.org/ghc/ghc/-/issues/22655TH + out-of-scope variable panic2023-01-17T14:53:42ZKrzysztof GogolewskiTH + out-of-scope variable panicThis silly program, which splices an out-of-scope variable, causes a panic:
```haskell
{-# OPTIONS_GHC -fdefer-out-of-scope-variables #-}
{-# LANGUAGE TemplateHaskell #-}
module X where
import Language.Haskell.TH
a :: Code Q Int
a = [...This silly program, which splices an out-of-scope variable, causes a panic:
```haskell
{-# OPTIONS_GHC -fdefer-out-of-scope-variables #-}
{-# LANGUAGE TemplateHaskell #-}
module X where
import Language.Haskell.TH
a :: Code Q Int
a = [|| outOfScope ||]
```
```haskell
{-# LANGUAGE TemplateHaskell #-}
module Y where
import X
b = $$(a)
```
```
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.5.20221216:
unfilled unbound-variable evidence
a241
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/Tc/Utils/TcMType.hs:307:27 in ghc:GHC.Tc.Utils.TcMType
CallStack (from HasCallStack):
panic, called at compiler/GHC/Utils/Error.hs:454:29 in ghc:GHC.Utils.Error
```https://gitlab.haskell.org/ghc/ghc/-/issues/22547Core Lint error with a type family2023-05-25T13:51:43ZKrzysztof GogolewskiCore Lint error with a type familyThe following program fails Core Lint
```haskell
{-# LANGUAGE TypeFamilies #-}
module M where
import Data.Kind (Type)
data MP1 a = MP1 a
type family Fixup (f :: Type) (g :: Type) :: Type where
Fixup f (MP1 f) = MP1 f
Fixup f f = ...The following program fails Core Lint
```haskell
{-# LANGUAGE TypeFamilies #-}
module M where
import Data.Kind (Type)
data MP1 a = MP1 a
type family Fixup (f :: Type) (g :: Type) :: Type where
Fixup f (MP1 f) = MP1 f
Fixup f f = f
```
```
*** Core Lint errors : in result of TcGblEnv axioms ***
M.hs:8:13: warning:
Incorrect incompatible branch: CoAxBranch (M.hs:9:3-25): [f_aw2,
MP1 f_aw2] => MP1 f_aw2
In the coercion axiom D:R:Fixup :: {[f_aw2].
Fixup f_aw2 (MP1 f_aw2)
~_N
MP1 f_aw2
[f_aw3]. Fixup f_aw3 f_aw3 ~_N f_aw3}
```
Credit to @alt-romes for finding this issue in linear-base; I've only minimized it.Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/22535Regression: infinite loop on quantified constraints2022-12-13T00:10:12ZThomas WinantRegression: infinite loop on quantified constraints```haskell
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE QuantifiedConstraints #-}
module Test where
class Eq r => Op op r
class (forall r. Eq r => Op op r) => HasResult op
foo :: HasResult op => op -> Bool
foo _ = True == False
...```haskell
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE QuantifiedConstraints #-}
module Test where
class Eq r => Op op r
class (forall r. Eq r => Op op r) => HasResult op
foo :: HasResult op => op -> Bool
foo _ = True == False
```
GHC 8.10.7 accepts the above program, but GHC 9.0.2, 9.2.5, 9.4.3, and a [recent git release](https://gitlab.haskell.org/ghc/ghc/-/commit/11627c422cfba5e1d84afb08f427007dbc801f10/) all reject it with:
```
Test.hs:9:14: error:
• Reduction stack overflow; size = 201
When simplifying the following type: Eq Bool
Use -freduction-depth=0 to disable this check
(any upper bound you could choose might fail unpredictably with
minor updates to GHC, so disabling the check is recommended if
you're sure that type checking should terminate)
• In the expression: True == False
In an equation for ‘foo’: foo _ = True == False
```
Raising the bound or disabling the check doesn't help.
Removing the `HasResult op` constraint from `foo` makes the program compile again.
It seems that GHC, when it tries to solve the `Eq Bool` constraint, is not using the top-level instance, but looping via the quantified constraint of the local `HasResult` constraint.https://gitlab.haskell.org/ghc/ghc/-/issues/22491refineFromInScope panic with -O2 on GHC 9.2.5/9.4.3 (but not on 9.2.4/9.4.2)2023-02-14T18:47:37ZRyan ScottrefineFromInScope panic with -O2 on GHC 9.2.5/9.4.3 (but not on 9.2.4/9.4.2)The [`saw-script`](https://github.com/GaloisInc/saw-script/) repository panics when built with GHC 9.2.5, but not with GHC 9.2.4. Here is a somewhat minimal reproducer with no external dependencies:
<details>
```hs
{-# LANGUAGE Haskell...The [`saw-script`](https://github.com/GaloisInc/saw-script/) repository panics when built with GHC 9.2.5, but not with GHC 9.2.4. Here is a somewhat minimal reproducer with no external dependencies:
<details>
```hs
{-# LANGUAGE Haskell2010 #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module SAWScript.HeapsterBuiltins (heapster_add_block_hints) where
import qualified Control.Exception as X
import Control.Applicative
import Control.Monad
import Control.Monad.Catch (MonadThrow(..), MonadCatch(..), catches, Handler(..))
import Control.Monad.IO.Class
import qualified Control.Monad.Fail as Fail
import Control.Monad.Trans.Class (MonadTrans(..))
import Control.Monad.Trans.Reader (ReaderT)
import Data.Coerce (Coercible, coerce)
import Data.IORef
import Data.Kind (Type)
import Data.Monoid
import GHC.Exts (build)
failOnNothing :: Fail.MonadFail m => String -> Maybe a -> m a
failOnNothing err_str Nothing = Fail.fail err_str
failOnNothing _ (Just a) = return a
lookupLLVMSymbolModAndCFG :: HeapsterEnv -> String -> IO (Maybe (AnyCFG LLVM))
lookupLLVMSymbolModAndCFG _ _ = pure Nothing
heapster_add_block_hints :: HeapsterEnv -> String -> [Int] ->
(forall ext blocks ret.
CFG ext blocks ret ->
TopLevel Hint) ->
TopLevel ()
heapster_add_block_hints henv nm blks hintF =
do env <- liftIO $ readIORef $ heapsterEnvPermEnvRef henv
AnyCFG cfg <-
failOnNothing ("Could not find symbol definition: " ++ nm) =<<
io (lookupLLVMSymbolModAndCFG henv nm)
let blocks = fmapFC blockInputs $ cfgBlockMap cfg
block_idxs = fmapFC (blockIDIndex . blockID) $ cfgBlockMap cfg
blkIDs <- case blks of
[] -> pure $ toListFC (Some . BlockID) block_idxs
_ -> forM blks $ \blk ->
failOnNothing ("Block ID " ++ show blk ++
" not found in function " ++ nm)
(fmapF BlockID <$> intIndex blk (size blocks))
env' <- foldM (\env' _ ->
permEnvAddHint env' <$>
hintF cfg)
env blkIDs
liftIO $ writeIORef (heapsterEnvPermEnvRef henv) env'
-----
data Some (f:: k -> Type) = forall x . Some (f x)
class FunctorF m where
fmapF :: (forall x . f x -> g x) -> m f -> m g
mapSome :: (forall tp . f tp -> g tp) -> Some f -> Some g
mapSome f (Some x) = Some $! f x
instance FunctorF Some where fmapF = mapSome
type SingleCtx x = EmptyCtx ::> x
data Ctx k
= EmptyCtx
| Ctx k ::> k
type family (<+>) (x :: Ctx k) (y :: Ctx k) :: Ctx k where
x <+> EmptyCtx = x
x <+> (y ::> e) = (x <+> y) ::> e
data Height = Zero | Succ Height
data BalancedTree h (f :: k -> Type) (p :: Ctx k) where
BalLeaf :: !(f x) -> BalancedTree 'Zero f (SingleCtx x)
BalPair :: !(BalancedTree h f x)
-> !(BalancedTree h f y)
-> BalancedTree ('Succ h) f (x <+> y)
data BinomialTree (h::Height) (f :: k -> Type) :: Ctx k -> Type where
Empty :: BinomialTree h f EmptyCtx
PlusOne :: !Int
-> !(BinomialTree ('Succ h) f x)
-> !(BalancedTree h f y)
-> BinomialTree h f (x <+> y)
PlusZero :: !Int
-> !(BinomialTree ('Succ h) f x)
-> BinomialTree h f x
tsize :: BinomialTree h f a -> Int
tsize Empty = 0
tsize (PlusOne s _ _) = 2*s+1
tsize (PlusZero s _) = 2*s
fmap_bin :: (forall tp . f tp -> g tp)
-> BinomialTree h f c
-> BinomialTree h g c
fmap_bin _ Empty = Empty
fmap_bin f (PlusOne s t x) = PlusOne s (fmap_bin f t) (fmap_bal f x)
fmap_bin f (PlusZero s t) = PlusZero s (fmap_bin f t)
{-# INLINABLE fmap_bin #-}
fmap_bal :: (forall tp . f tp -> g tp)
-> BalancedTree h f c
-> BalancedTree h g c
fmap_bal = go
where go :: (forall tp . f tp -> g tp)
-> BalancedTree h f c
-> BalancedTree h g c
go f (BalLeaf x) = BalLeaf (f x)
go f (BalPair x y) = BalPair (go f x) (go f y)
{-# INLINABLE fmap_bal #-}
traverse_bin :: Applicative m
=> (forall tp . f tp -> m (g tp))
-> BinomialTree h f c
-> m (BinomialTree h g c)
traverse_bin _ Empty = pure Empty
traverse_bin f (PlusOne s t x) = PlusOne s <$> traverse_bin f t <*> traverse_bal f x
traverse_bin f (PlusZero s t) = PlusZero s <$> traverse_bin f t
{-# INLINABLE traverse_bin #-}
traverse_bal :: Applicative m
=> (forall tp . f tp -> m (g tp))
-> BalancedTree h f c
-> m (BalancedTree h g c)
traverse_bal = go
where go :: Applicative m
=> (forall tp . f tp -> m (g tp))
-> BalancedTree h f c
-> m (BalancedTree h g c)
go f (BalLeaf x) = BalLeaf <$> f x
go f (BalPair x y) = BalPair <$> go f x <*> go f y
{-# INLINABLE traverse_bal #-}
data Assignment (f :: k -> Type) (ctx :: Ctx k)
= Assignment (BinomialTree 'Zero f ctx)
newtype Index (ctx :: Ctx k) (tp :: k) = Index { indexVal :: Int }
newtype Size (ctx :: Ctx k) = Size Int
intIndex :: Int -> Size ctx -> Maybe (Some (Index ctx))
intIndex i n | 0 <= i && i < sizeInt n = Just (Some (Index i))
| otherwise = Nothing
size :: Assignment f ctx -> Size ctx
size (Assignment t) = Size (tsize t)
sizeInt :: Size ctx -> Int
sizeInt (Size n) = n
class FunctorFC (t :: (k -> Type) -> l -> Type) where
fmapFC :: forall f g. (forall x. f x -> g x) ->
(forall x. t f x -> t g x)
(#.) :: Coercible b c => (b -> c) -> (a -> b) -> (a -> c)
(#.) _f = coerce
class FoldableFC (t :: (k -> Type) -> l -> Type) where
foldMapFC :: forall f m. Monoid m => (forall x. f x -> m) -> (forall x. t f x -> m)
foldMapFC f = foldrFC (mappend . f) mempty
foldrFC :: forall f b. (forall x. f x -> b -> b) -> (forall x. b -> t f x -> b)
foldrFC f z t = appEndo (foldMapFC (Endo #. f) t) z
toListFC :: forall f a. (forall x. f x -> a) -> (forall x. t f x -> [a])
toListFC f t = build (\c n -> foldrFC (\e v -> c (f e) v) n t)
foldMapFCDefault :: (TraversableFC t, Monoid m) => (forall x. f x -> m) -> (forall x. t f x -> m)
foldMapFCDefault = \f -> getConst . traverseFC (Const . f)
{-# INLINE foldMapFCDefault #-}
class (FunctorFC t, FoldableFC t) => TraversableFC (t :: (k -> Type) -> l -> Type) where
traverseFC :: forall f g m. Applicative m
=> (forall x. f x -> m (g x))
-> (forall x. t f x -> m (t g x))
instance FunctorFC Assignment where
fmapFC = \f (Assignment x) -> Assignment (fmap_bin f x)
{-# INLINE fmapFC #-}
instance FoldableFC Assignment where
foldMapFC = foldMapFCDefault
{-# INLINE foldMapFC #-}
instance TraversableFC Assignment where
traverseFC = \f (Assignment x) -> Assignment <$> traverse_bin f x
{-# INLINE traverseFC #-}
data CrucibleType
data TypeRepr (tp::CrucibleType) where
type CtxRepr = Assignment TypeRepr
data CFG (ext :: Type)
(blocks :: Ctx (Ctx CrucibleType))
(ret :: CrucibleType)
= CFG { cfgBlockMap :: !(BlockMap ext blocks ret)
}
type BlockMap ext blocks ret = Assignment (Block ext blocks ret) blocks
data Block ext (blocks :: Ctx (Ctx CrucibleType)) (ret :: CrucibleType) ctx
= Block { blockID :: !(BlockID blocks ctx)
, blockInputs :: !(CtxRepr ctx)
}
newtype BlockID (blocks :: Ctx (Ctx CrucibleType)) (tp :: Ctx CrucibleType)
= BlockID { blockIDIndex :: Index blocks tp }
data LLVM
data AnyCFG ext where
AnyCFG :: CFG ext blocks ret
-> AnyCFG ext
newtype StateContT s r m a
= StateContT { runStateContT :: (a -> s -> m r)
-> s
-> m r
}
fmapStateContT :: (a -> b) -> StateContT s r m a -> StateContT s r m b
fmapStateContT = \f m -> StateContT $ \c -> runStateContT m (\v s -> (c $! f v) s)
{-# INLINE fmapStateContT #-}
applyStateContT :: StateContT s r m (a -> b) -> StateContT s r m a -> StateContT s r m b
applyStateContT = \mf mv ->
StateContT $ \c ->
runStateContT mf (\f -> runStateContT mv (\v s -> (c $! f v) s))
{-# INLINE applyStateContT #-}
returnStateContT :: a -> StateContT s r m a
returnStateContT = \v -> seq v $ StateContT $ \c -> c v
{-# INLINE returnStateContT #-}
bindStateContT :: StateContT s r m a -> (a -> StateContT s r m b) -> StateContT s r m b
bindStateContT = \m n -> StateContT $ \c -> runStateContT m (\a -> runStateContT (n a) c)
{-# INLINE bindStateContT #-}
instance Functor (StateContT s r m) where
fmap = fmapStateContT
instance Applicative (StateContT s r m) where
pure = returnStateContT
(<*>) = applyStateContT
instance Monad (StateContT s r m) where
(>>=) = bindStateContT
instance MonadFail m => MonadFail (StateContT s r m) where
fail = \msg -> StateContT $ \_ _ -> fail msg
instance MonadTrans (StateContT s r) where
lift = \m -> StateContT $ \c s -> m >>= \v -> seq v (c v s)
instance MonadIO m => MonadIO (StateContT s r m) where
liftIO = lift . liftIO
instance MonadThrow m => MonadThrow (StateContT s r m) where
throwM e = StateContT (\_k _s -> throwM e)
instance MonadCatch m => MonadCatch (StateContT s r m) where
catch m hdl =
StateContT $ \k s ->
catch
(runStateContT m k s)
(\e -> runStateContT (hdl e) k s)
data TopLevelRO
data TopLevelRW
data Value
newtype TopLevel a =
TopLevel_ (ReaderT TopLevelRO (StateContT TopLevelRW (Value, TopLevelRW) IO) a)
deriving (Applicative, Functor, Monad, MonadFail, MonadThrow, MonadCatch)
instance MonadIO TopLevel where
liftIO = io
io :: IO a -> TopLevel a
io f = TopLevel_ (liftIO f) `catches` [Handler handleIO]
where
rethrow :: X.Exception ex => ex -> TopLevel a
rethrow ex = throwM (X.SomeException ex)
handleIO :: X.IOException -> TopLevel a
handleIO = rethrow
data HeapsterEnv = HeapsterEnv {
heapsterEnvPermEnvRef :: IORef PermEnv
}
data Hint where
data PermEnv = PermEnv {
permEnvHints :: [Hint]
}
permEnvAddHint :: PermEnv -> Hint -> PermEnv
permEnvAddHint env hint = env { permEnvHints = hint : permEnvHints env }
type family CtxToRList (ctx :: Ctx k) :: RList k where
CtxToRList EmptyCtx = RNil
CtxToRList (ctx' ::> x) = CtxToRList ctx' :> x
data RList a
= RNil
| (RList a) :> a
```
</details>
This will panic when built with `-O2` using GHC 9.2.5 or 9.4.3:
<details>
```
$ ghc-9.2.5 Bug.hs -O2 -fforce-recomp
[1 of 1] Compiling SAWScript.HeapsterBuiltins ( Bug.hs, Bug.o )
ghc: panic! (the 'impossible' happened)
(GHC version 9.2.5:
refineFromInScope
InScope {wild_00 eta_B0 eta_B1 eta_B2 eta_B3 eta_X3 eta_X4 eta_Xb
eta_Xc eta_Xd a_Xk eta_Xl eta_Xm wild_Xo v_Xp exit_Xr a_Xs eta_Xt
a_a128 henv_a129 nm_a12a blks_a12b hintF_a12c a_a1tQ
$cp1MonadCatch_a345 $cliftIO_a35g $c>>_a36S $cfoldrFC_a3a4
$ctoListFC_a3ap $cfmapF_a3ba $krep_a5fW $krep_a5fY $krep_a5fZ
$krep_a5g0 $krep_a5g1 $krep_a5g2 $krep_a5g3 $krep_a5g4 $krep_a5g5
$krep_a5g6 $krep_a5g7 $krep_a5g8 $krep_a5g9 $krep_a5ga $krep_a5gb
$krep_a5gc $krep_a5gd $krep_a5ge $krep_a5gf $krep_a5gg $krep_a5gh
$krep_a5gi $krep_a5gj $krep_a5gk $krep_a5gl $krep_a5gm $krep_a5go
$krep_a5gq $krep_a5gr $krep_a5gs $krep_a5gt $krep_a5gu $krep_a5gv
$krep_a5gy $krep_a5gz $krep_a5gA $krep_a5gB $krep_a5gC $krep_a5gD
$krep_a5gE $krep_a5gF $krep_a5gG $krep_a5gH $krep_a5gI $krep_a5gJ
$krep_a5gK $krep_a5gL $krep_a5gM $krep_a5gN $krep_a5gP $krep_a5gQ
$krep_a5gR $krep_a5gS $krep_a5gT $krep_a5gU $krep_a5gW $krep_a5gX
$krep_a5gY $krep_a5gZ $krep_a5h1 $krep_a5h2 $krep_a5h3 $krep_a5h4
$krep_a5h5 $krep_a5h6 $krep_a5h7 $krep_a5h8 $krep_a5h9 $krep_a5ha
$krep_a5hc $krep_a5hd $krep_a5he $krep_a5hf $krep_a5hg $krep_a5hh
$krep_a5hi $krep_a5hl $krep_a5hm $krep_a5hn $krep_a5ho $krep_a5hr
$krep_a5hs $krep_a5ht $krep_a5hu $krep_a5hv $krep_a5hx $krep_a5hy
$krep_a5hz $krep_a5hA $krep_a5hB $krep_a5hC $krep_a5hD $krep_a5hE
$krep_a5hF $krep_a5hG $krep_a5hH $krep_a5hI r1_a5BO e1_a5E3
eta1_a5E4 permEnvHints heapsterEnvPermEnvRef runStateContT
blockIDIndex blockID blockInputs cfgBlockMap indexVal
heapster_add_block_hints fmap_bin fmap_bal traverse_bin
traverse_bal $tc'Some $tcSome $tcFunctorF $fFunctorFkSome
$tc'EmptyCtx $tc'::> $tcCtx $tc'Zero $tc'Succ $tcHeight $tc'BalLeaf
$tcBalancedTree $tc'Empty $tc'PlusZero $tcBinomialTree
$tc'Assignment $tcAssignment $tc'Index $tcIndex $tc'Size $tcSize
$tcFunctorFC $fFunctorFCkCtxAssignment $tcFoldableFC $dmfoldMapFC
$dmfoldrFC $dmtoListFC $fFoldableFCkCtxAssignment $tcTraversableFC
$fTraversableFCkCtxAssignment $tcCrucibleType $tcTypeRepr
$tc'BlockID $tcBlockID $tc'Block $tcBlock $tc'CFG $tcCFG $tcLLVM
$tc'AnyCFG $tcAnyCFG $tc'StateContT $tcStateContT
$fMonadCatchStateContT $fMonadThrowStateContT $fMonadIOStateContT
$fMonadTransStateContT $fMonadFailStateContT $fMonadStateContT
$fApplicativeStateContT $fFunctorStateContT $tcTopLevelRO
$tcTopLevelRW $tcValue $tc'TopLevel_ $tcTopLevel $fMonadIOTopLevel
$tcHint $tc'PermEnv $tcPermEnv $tc'HeapsterEnv $tcHeapsterEnv
$tc'RNil $tc':> $tcRList $fApplicativeTopLevel $fFunctorTopLevel
$fMonadTopLevel $fMonadFailTopLevel $fMonadThrowTopLevel
$fMonadCatchTopLevel $trModule $clift_s5zq indexVal_s5zu
blockIDIndex_s5zv runStateContT_s5zw $ccatch_s5zx go_s5zy
$fTraversableFCkCtxAssignment_s5zH
$fTraversableFCkCtxAssignment_s5zI $fFunctorStateContT_s5A1
$c<$_s5A2 $fApplicativeStateContT_s5At $fApplicativeStateContT_s5Au
$fMonadStateContT_s5BE $creturn_s5BG $c>>_s5C9 $trModule_s5El
$trModule_s5Em $trModule_s5En $trModule_s5Eo $tcSome_s5EI
$tcSome_s5EJ $krep_s5EK $tc'Some_s5EM $tc'Some_s5EN
$tcFunctorF_s5EO $tcFunctorF_s5EP $tcCtx_s5EQ $tcCtx_s5ER
$krep_s5ES $tc'EmptyCtx_s5ET $tc'EmptyCtx_s5EU $tc'::>_s5EW
$tc'::>_s5EX $krep_s5EY $krep_s5EZ $krep_s5F0 $tcHeight_s5F1
$tcHeight_s5F2 $tc'Zero_s5F3 $tc'Zero_s5F4 $tc'Succ_s5F5
$tc'Succ_s5F6 $tcBalancedTree_s5F8 $tcBalancedTree_s5F9 $krep_s5Fa
$krep_s5Fb $krep_s5Fc $krep_s5Fd $tc'BalLeaf_s5Fe $tc'BalLeaf_s5Ff
$tcBinomialTree_s5Fg $tcBinomialTree_s5Fh $krep_s5Fi $krep_s5Fj
$krep_s5Fk $krep_s5Fl $krep_s5Fm $krep_s5Fn $krep_s5Fo $krep_s5Fp
$tc'Empty_s5Fq $tc'Empty_s5Fr $krep_s5Fu $krep_s5Fv
$tc'PlusZero_s5Fw $tc'PlusZero_s5Fx $krep_s5FA $krep_s5FB
$tcAssignment_s5FC $tcAssignment_s5FD $krep_s5FG
$tc'Assignment_s5FH $tc'Assignment_s5FI $tcIndex_s5FJ $tcIndex_s5FK
$krep_s5FM $tc'Index_s5FO $tc'Index_s5FP $tcSize_s5FQ $tcSize_s5FR
$tc'Size_s5FU $tc'Size_s5FV $tcFunctorFC_s5FW $tcFunctorFC_s5FX
$tcFoldableFC_s5FY $tcFoldableFC_s5FZ $tcTraversableFC_s5G0
$tcTraversableFC_s5G1 $tcCrucibleType_s5G2 $tcCrucibleType_s5G3
$krep_s5G4 $krep_s5G6 $krep_s5G7 $krep_s5G8 $tcTypeRepr_s5G9
$tcTypeRepr_s5Ga $krep_s5Gb $krep_s5Gc $krep_s5Gd $tcBlockID_s5Ge
$tcBlockID_s5Gf $tc'BlockID_s5Gi $tc'BlockID_s5Gj $krep_s5Gl
$tcBlock_s5Gm $tcBlock_s5Gn $krep_s5Gr $krep_s5Gt $krep_s5Gu
$tc'Block_s5GA $tc'Block_s5GB $tcCFG_s5GC $tcCFG_s5GD $tc'CFG_s5GH
$tc'CFG_s5GI $tcLLVM_s5GJ $tcLLVM_s5GK $tcAnyCFG_s5GL
$tcAnyCFG_s5GM $tc'AnyCFG_s5GO $tc'AnyCFG_s5GP $tcStateContT_s5GQ
$tcStateContT_s5GR $krep_s5GT $krep_s5GU $krep_s5GV $krep_s5GW
$tc'StateContT_s5GX $tc'StateContT_s5GY $tcTopLevelRO_s5GZ
$tcTopLevelRO_s5H0 $tcTopLevelRW_s5H1 $tcTopLevelRW_s5H2
$tcValue_s5H3 $tcValue_s5H4 $krep_s5H5 $krep_s5H6 $krep_s5H7
$krep_s5H8 $krep_s5H9 $krep_s5Ha $krep_s5Hc $krep_s5Hd
$tcTopLevel_s5He $tcTopLevel_s5Hf $tc'TopLevel__s5Hh
$tc'TopLevel__s5Hi $tcHint_s5Hj $tcHint_s5Hk $krep_s5Hl
$tcPermEnv_s5Hm $tcPermEnv_s5Hn $tc'PermEnv_s5Ho $tc'PermEnv_s5Hp
$krep_s5Hq $tcHeapsterEnv_s5Hr $tcHeapsterEnv_s5Hs
$tc'HeapsterEnv_s5Ht $tc'HeapsterEnv_s5Hu $tcRList_s5Hv
$tcRList_s5Hw $tc'RNil_s5Hy $tc'RNil_s5Hz $tc':>_s5HA $tc':>_s5HB
$fFoldableFCkCtxAssignment_s5Po $c*>_s5Pp $cliftA2_s5Pq $c<*_s5Ps
$creturn_s5Pu $cthrowM_s5Pv $ccatch_s5Pw ipv_s5PP ipv_s5PQ ipv_s5PR
$s$fMonadFailStateContT_s5Ro $scatches_s5RP $sfoldlM_s5Se
$s$fMonadFailReaderT_$cfail_s5Sz $s$fMonadReaderT_$c>>=_s5SB
$s$fApplicativeReaderT_$c<*_s5SD $s$fApplicativeReaderT_$c*>_s5SF
$s$fApplicativeReaderT_$cliftA2_s5SH
$s$fApplicativeReaderT_$c<*>_s5SJ $s$fFunctorReaderT_$c<$_s5SN
$s$fFunctorReaderT_$cfmap_s5SP go_s5T6 lvl_s5T7 lvl_s5T8 lvl_s5Tb
lvl_s5Tc lvl_s5Tf eta_s5Tj m1_s5Tn lvl_s5Tp lvl_s5Tq lvl_s5Tx
lvl_s5Ty lvl_s5TB karg_s5U0 io_s5Up lvl_s5Us go1_s5Uz eta_s5UI
$wgo_s5Vj lvl_s5Xj lvl_s5Xk lvl_s5Xl lvl_s5Xm sc_s5Xw sc_s5Xx
sc_s5Xy sg_s5Xz $sgo1_s5XA $sgo1_s5ZU}
eta_B4
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Opt/Simplify/Env.hs:706:30 in ghc:GHC.Core.Opt.Simplify.Env
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
</details>
On the other hand, this does _not_ panic when built with 9.2.4 or 9.4.2:
<details>
```
$ ghc-9.2.4 Bug.hs -O2 -fforce-recomp
[1 of 1] Compiling SAWScript.HeapsterBuiltins ( Bug.hs, Bug.o )
$ ghc-9.4.2 Bug.hs -O2 -fforce-recomp
[1 of 1] Compiling SAWScript.HeapsterBuiltins ( Bug.hs, Bug.o )
```
</details>9.2.6https://gitlab.haskell.org/ghc/ghc/-/issues/224829.2.5 panic ((RUBBISH[LiftedRep] @(IO ()))2023-10-02T13:49:06Zjwaldmann9.2.5 panic ((RUBBISH[LiftedRep] @(IO ()))I am seeing this
```
ghc: panic! (the 'impossible' happened)
(GHC version 9.2.5:
CoreToStg.myCollectArgs
((RUBBISH[LiftedRep] @(IO ()))
`cast` (N:IO[0] <()>_R
:: IO () ~R# (State# RealWorld -> (# State# RealWorld, () #...I am seeing this
```
ghc: panic! (the 'impossible' happened)
(GHC version 9.2.5:
CoreToStg.myCollectArgs
((RUBBISH[LiftedRep] @(IO ()))
`cast` (N:IO[0] <()>_R
:: IO () ~R# (State# RealWorld -> (# State# RealWorld, () #))))
ipv4_sj1F
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/CoreToStg.hs:969:33 in ghc:GHC.CoreToStg
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
It happens in a large project https://gitlab.imn.htwk-leipzig.de/autotool/all0/-/jobs/110022
Do you want me to isolate this?
you can reproduce with
```
git clone https://gitlab.imn.htwk-leipzig.de/autotool/all0/
cd all0
git checkout 931-move-to-ghc-9-2-stackage-lts-20
git submodule init
git submodule update
stack build autotool-collection:exe:declarative-graphics
```
#19824 has a similar error9.2.5ZubinZubinhttps://gitlab.haskell.org/ghc/ghc/-/issues/22459ASSERT failed in_scope InScope2024-03-19T18:02:19ZBodigrimASSERT failed in_scope InScope## Summary
GHC 9.4.3 compiles a program successfully, while GHC HEAD 9.5.20221111 (obtained from https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/raw/ghc-x86_64-darwin-validate.tar.xz?job=x86_64-darwin-validate) fails with a p...## Summary
GHC 9.4.3 compiles a program successfully, while GHC HEAD 9.5.20221111 (obtained from https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/raw/ghc-x86_64-darwin-validate.tar.xz?job=x86_64-darwin-validate) fails with a panic.
## Steps to reproduce
Save this as `Bug.hs`:
```haskell
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -O #-}
module Lib (foo) where
import qualified Data.Map as M
newtype Fix f = Fix (f (Fix f))
instance Eq (f (Fix f)) => Eq (Fix f) where
Fix a == Fix b = a == b
instance Ord (f (Fix f)) => Ord (Fix f) where
Fix a `compare` Fix b = a `compare` b
data Foo i r = Foo i r
deriving (Eq, Ord)
newtype Bar a = Bar (M.Map Char (M.Map (Fix (Foo ())) Word))
foo :: Bar a -> Bar a -> Bar a
foo (Bar a) (Bar b) = Bar (M.unionWith M.union a b)
```
Now run:
```
$ ghc-9.4.3 Bug.hs
[1 of 1] Compiling Lib ( Bug.hs, Bug.o )
$ ghc-head Bug.hs
[1 of 1] Compiling Lib ( Bug.hs, Bug.o )
WARNING:
Glomming in
Lib:
[s1oC :->, s1ri :->, s1rw :-> OnceL1!, s1sq :->, s1t1 :-> OnceL1!,
s1tC :-> OnceL1!]
Call stack:
CallStack (from HasCallStack):
warnPprTrace, called at compiler/GHC/Core/Opt/OccurAnal.hs:91:5 in ghc:GHC.Core.Opt.OccurAnal
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.5.20221111:
ASSERT failed!
in_scope InScope {wild_00 wild_X1 wild_X2 a1_a11M a2_a11N b1_a11O
b2_a11P $c==_a12P $c/=_a131 $cp1Ord_a13h $ccompare_a13j $c<_a13G
$c<=_a140 $c>=_a14e $cmax_a14m $cmin_a14u $cp1Ord_a14I $c<_a14U
$c<=_a152 $c>_a15a $cmax_a15p $cmin_a15w $c/=_a15R $krep_a1ig
$krep_a1ih $krep_a1ii $krep_a1ij $krep_a1ik $krep_a1il $krep_a1im
$krep_a1in $krep_a1io $krep_a1ip $krep_a1iq $krep_a1ir $krep_a1is
$krep_a1it $krep_a1iu $krep_a1iv $krep_a1iw $krep_a1ix $krep_a1iy
$krep_a1iz $krep_a1iA wild_a1pe bx_a1pf kx_a1pg x_a1ph l_a1pi
r_a1pj wild_a1ux wild1_a1uz foo $tc'Fix $tcFix $fOrdFix $fEqFix
$tc'Foo $tcFoo $tc'Bar $tcBar $fEqFoo $fOrdFoo $trModule $dOrd_s1nX
$dOrd_s1nY foo_s1nZ $trModule_s1o0 $trModule_s1o1 $trModule_s1o2
$trModule_s1o3 $tcFix_s1o8 $tcFix_s1o9 $krep_s1oa $tc'Fix_s1ob
$tc'Fix_s1oc $tcFoo_s1od $tcFoo_s1oe $krep_s1of $krep_s1og
$krep_s1oh $krep_s1oi $krep_s1oj $krep_s1ok $krep_s1ol $krep_s1om
$tc'Foo_s1on $tc'Foo_s1oo $tcBar_s1op $tcBar_s1oq $krep_s1or
$krep_s1os $tc'Bar_s1ot $tc'Bar_s1ou $sunion_s1oC $ssplit_s1oP
$s$wsplit_s1pH $sinsert_s1qy $sinsertR_s1rc $sunionWith_s1ri
$ssplitLookup_s1rw $s$wsplitLookup_s1sq poly_go15_s1tE lvl_s1tF
$sgo15_s1tH $sgo15_s1tM $sgo15_s1tR lvl_s1tT $sgo15_s1tW
$sgo15_s1u1 $w$cmax_s1vW $w$cmin_s1we $w$c<=_s1wv $w$c>=_s1wM
a_s1xC k2_s1xD t_s1xE $wpoly_go15_s1xH $w$sgo15_s1xZ $w$sgo15_s1yh
$w$sgo15_s1yI $j_s1zD}
tenv [a1oR :-> a_s1xC]
cenv []
tys [a_a12r]
cos []
needInScope {a_a12r}
Call stack:
CallStack (from HasCallStack):
assertPpr, called at compiler/GHC/Core/TyCo/Subst.hs:696:5 in ghc:GHC.Core.TyCo.Subst
checkValidSubst, called at compiler/GHC/Core/TyCo/Subst.hs:720:29 in ghc:GHC.Core.TyCo.Subst
substTy, called at compiler/GHC/Core/Opt/Simplify/Env.hs:1233:18 in ghc:GHC.Core.Opt.Simplify.Env
substTy, called at compiler/GHC/Core/Opt/Simplify/Iteration.hs:1306:14 in ghc:GHC.Core.Opt.Simplify.Iteration
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
## Expected behavior
I'd expect both versions of GHC to compile successfully.
## Environment
* GHC version used: GHC HEAD 9.5.202211119.6.1Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/22417HEAD segfaults on Windows when building large packages (e.g., lsp-types)2023-04-11T08:19:40ZRyan ScottHEAD segfaults on Windows when building large packages (e.g., lsp-types)When using nightly Windows HEAD bindists, I have noticed that it will segfault when building large packages. Unfortunately, I don't know of a minimal way to reproduce the bug other than to build a large Hackage library with `head.hackage...When using nightly Windows HEAD bindists, I have noticed that it will segfault when building large packages. Unfortunately, I don't know of a minimal way to reproduce the bug other than to build a large Hackage library with `head.hackage`. The `lsp-types-1.6.0.0` library provides a good example of this. To reproduce, do the following:
1. Download a nightly [`x86_64-windows-validate`](https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/download?job=x86_64-windows-validate) bindist. At the time of writing, I am using the one from [here](https://gitlab.haskell.org/ghc/ghc/-/jobs/1221538/artifacts/download), at commit 3c0e379322965aa87b14923f6d8e1ef5cd677925.
2. Using [`head.hackage`](https://gitlab.haskell.org/ghc/head.hackage/), check out the `lsp-types-1.6.0.0` library:
```
./head.hackage/scripts/patch-tool unpack lsp-types-1.6.0.0
```
3. Build `lsp-types-1.6.0.0` using the nightly Windows bindist. It should eventually produce a segfault that looks roughly like this one:
```
$ cabal build lsp-types
<elided>
[45 of 52] Compiling Language.LSP.Types.Registration ( src\Language\LSP\Types\Registration.hs, C:\\Users\winferno\Documents\Hacki
ng\Haskell\staging\dist-newstyle\build\x86_64-windows\ghc-9.5.20221105\lsp-types-1.6.0.0\build\Language\LSP\Types\Registration.o
)
src\Language\LSP\Types\Registration.hs:128:1: error: [GHC-55017]
Illegal type variable name: `'
When splicing a TH declaration
Access violation in generated code when executing data at 0x7ff6992263d9
Attempting to reconstruct a stack trace...
Frame Code address
* 0xe29c6fd9f0 0x7ff6992263d9 C:\Users\winferno\Software\ghc-9.5.20221105\bin\ghc-9.5.20221105.exe+0x50363d9
Error: cabal-3.8.1.0.exe: Failed to build lsp-types-1.6.0.0. The build process
terminated with exit code 11
```
I've also seen the segfault happen without the `Illegal type variable name` part:
```
[45 of 52] Compiling Language.LSP.Types.Registration ( src\Language\LSP\Types\Registration.hs, C:\\Users\winferno\Documents\Hacki
ng\Haskell\staging\dist-newstyle\build\x86_64-windows\ghc-9.5.20221105\lsp-types-1.6.0.0\build\Language\LSP\Types\Registration.o
)
Access violation in generated code when reading 0xffffffffffffffff
Attempting to reconstruct a stack trace...
Frame Code address
* 0xc27adfd970 0x7ff695a5c188 C:\Users\winferno\Software\ghc-9.5.20221105\bin\ghc-9.5.20221105.exe+0x186c188
Error: cabal-3.8.1.0.exe: Failed to build lsp-types-1.6.0.0. The build process
terminated with exit code 11
```
4. Curiously, if you re-run `cabal build lsp-types`, it will be able to compile the module that segfaulted above (`Language.LSP.Types.Registration`), but it will segfault on a later module:
```
$ cabal build lsp-types
<elided>
[47 of 52] Compiling Language.LSP.Types.Initialize ( src\Language\LSP\Types\Initialize.hs, C:\\Users\winferno\Documents\Hacking\H
askell\staging\dist-newstyle\build\x86_64-windows\ghc-9.5.20221105\lsp-types-1.6.0.0\build\Language\LSP\Types\Initialize.o )
Access violation in generated code when executing data at 0x7ef4cc37b0ba
Attempting to reconstruct a stack trace...
Frame Code address
* 0xeb45cfda80 0x7ef4cc37b0ba
Error: cabal-3.8.1.0.exe: Failed to build lsp-types-1.6.0.0. The build process
terminated with exit code 11
```
If I then re-run `cabal build lsp-types` a third time, then compilation will succeed.
On the other hand, if I run `cabal clean` and then run `cabal build lsp-tyes` afresh, then I will reliably reproduce the first segfault at `Language.LSP.Types.Registration` observed above.
As far as I can tell, this only affects HEAD, and not any GHC version from 9.4 or earlier.9.6.1Andreas KlebingerAndreas Klebingerhttps://gitlab.haskell.org/ghc/ghc/-/issues/22416ghc 9.4.3 panic with funResultTy2022-12-13T09:31:01ZDoug Burkeghc 9.4.3 panic with funResultTy## Summary
I mentioned this as part of #22171 but now that 9.4.3 has been released I wanted to make sure it's not lost.
Trying to compile the swish package results in
```
Building library for swish-0.10.2.0..
[ 1 of 55] Compiling Dat...## Summary
I mentioned this as part of #22171 but now that 9.4.3 has been released I wanted to make sure it's not lost.
Trying to compile the swish package results in
```
Building library for swish-0.10.2.0..
[ 1 of 55] Compiling Data.Interned.URI
[ 2 of 55] Compiling Data.Ord.Partial
[ 3 of 55] Compiling Data.String.ShowLines
[ 4 of 55] Compiling Network.URI.Ord
[ 5 of 55] Compiling Swish.GraphClass
[ 6 of 55] Compiling Swish.GraphMatch
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.4.3:
funResultTy
GenLabelMap lb_adso LabelIndex
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:182:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Type.hs:1334:49 in ghc:GHC.Core.Type
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
## Steps to reproduce
With GHC 9.4.3 (thanks ghcup)
```
% ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.4.3
```
we have
```
% git checkout https://gitlab.com/dburke/swish
% cd swish
% cabal install --allow-newer=base
Wrote tarball sdist to
/home/dburke/haskell/ghcup/swish/dist-newstyle/sdist/swish-0.10.2.0.tar.gz
Resolving dependencies...
Build profile: -w ghc-9.4.3 -O1
In order, the following will be built (use -v for more details):
- swish-0.10.2.0 (lib) (requires build)
- swish-0.10.2.0 (exe:Swish) (requires build)
Starting swish-0.10.2.0 (lib)
Building swish-0.10.2.0 (lib)
Failed to build swish-0.10.2.0.
Build log (
/home/dburke/.cabal/logs/ghc-9.4.3/swish-0.10.2.0-e3487166464e6bbde8ec07c43b2587c3fef0f74f131cda10f70441643557d8ef.log
):
Configuring library for swish-0.10.2.0..
Preprocessing library for swish-0.10.2.0..
Building library for swish-0.10.2.0..
[ 1 of 55] Compiling Data.Interned.URI
[ 2 of 55] Compiling Data.Ord.Partial
[ 3 of 55] Compiling Data.String.ShowLines
[ 4 of 55] Compiling Network.URI.Ord
[ 5 of 55] Compiling Swish.GraphClass
[ 6 of 55] Compiling Swish.GraphMatch
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.4.3:
funResultTy
GenLabelMap lb_adso LabelIndex
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:182:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Type.hs:1334:49 in ghc:GHC.Core.Type
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
[ 8 of 55] Compiling Swish.GraphPartition
[ 9 of 55] Compiling Swish.QName
...
... a lot of other stuff that's not relevant here
...
```
## Expected behavior
To be able to build and test the code
## Environment
* GHC version used: 9.4.3
Optional:
* Operating System: Linux
* System Architecture: x86_649.4.4https://gitlab.haskell.org/ghc/ghc/-/issues/22291Seemingly reasonable levity-polymorphic binding crashes code generator2023-07-21T17:14:18ZBen GamariSeemingly reasonable levity-polymorphic binding crashes code generatorConsider this program:
```haskell
module Hi where
import GHC.Exts
foo :: forall (lev :: Levity) (a :: TYPE (BoxedRep lev)). Addr# -> (# a #)
foo x = addrToAny# x
```
As of 112e4f9c9c299b460e37a60d8f8d8693aa6...Consider this program:
```haskell
module Hi where
import GHC.Exts
foo :: forall (lev :: Levity) (a :: TYPE (BoxedRep lev)). Addr# -> (# a #)
foo x = addrToAny# x
```
As of 112e4f9c9c299b460e37a60d8f8d8693aa6ab06a this crashes the code generator:
```
$ _build/stage1/bin/ghc hi.hs -XMagicHash -XUnboxedTuples -XRankNTypes -XKindSignatures -XPolyKinds -XDataKinds
[1 of 1] Compiling Hi ( hi.hs, hi.o )
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.5.20220906:
boxedRepDataCon
[lev_ayH]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:188:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Builtin/Types.hs:1628:9 in ghc:GHC.Builtin.Types
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
Noticed while implementing #20155 in !6245 .9.8.1Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/22235Scoping-related ASSERT failed on HEAD when building lsp-types2022-10-26T07:45:02ZRyan ScottScoping-related ASSERT failed on HEAD when building lsp-typesThe `lsp-types-1.6.0.0` Hackage library fails to build with HEAD when assertions are enabled. Here is a minimized reproducer:
```hs
{-# LANGUAGE Haskell2010 #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-...The `lsp-types-1.6.0.0` Hackage library fails to build with HEAD when assertions are enabled. Here is a minimized reproducer:
```hs
{-# LANGUAGE Haskell2010 #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
module Language.LSP.Types.Parsing (mEqServer) where
import Data.Text (Text)
import Data.Type.Equality ((:~:)(..), (:~~:)(..))
mEqServer :: SServerMethod m1 -> SServerMethod m2 -> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
mEqServer m1 m2 = go (splitServerMethod m1) (splitServerMethod m2)
where
go IsServerNot IsServerNot = do
Refl <- geq m1 m2
pure $ Right HRefl
go IsServerReq IsServerReq = do
Refl <- geq m1 m2
pure $ Right HRefl
go IsServerEither IsServerEither
| SCustomMethod c1 <- m1
, SCustomMethod c2 <- m2
, c1 == c2
= Just $ Left $ CustomEq HRefl
go _ _ = Nothing
-----
class GEq f where
geq :: f a -> f b -> Maybe (a :~: b)
data From = FromServer
data MethodType = Notification | Request
data Method (f :: From) (t :: MethodType) where
CancelRequest :: Method f Notification
CustomMethod :: Method f t
data SMethod (m :: Method f t) where
SCancelRequest :: SMethod CancelRequest
SCustomMethod :: Text -> SMethod CustomMethod
instance GEq SMethod where
geq (SCustomMethod x) (SCustomMethod y) =
if x == y then Just Refl else Nothing
geq SCancelRequest SCancelRequest = Just Refl
geq SCancelRequest SCustomMethod{} = Nothing
geq SCustomMethod{} SCancelRequest = Nothing
type SServerMethod (m :: Method FromServer t) = SMethod m
data ServerNotOrReq (m :: Method FromServer t) where
IsServerNot
:: ServerNotOrReq (m :: Method FromServer Notification)
IsServerReq
:: forall (m :: Method FromServer Request).
ServerNotOrReq m
IsServerEither
:: ServerNotOrReq CustomMethod
splitServerMethod :: SServerMethod m -> ServerNotOrReq m
splitServerMethod SCancelRequest = IsServerNot
splitServerMethod SCustomMethod{} = IsServerEither
data CustomEq m1 m2 where
CustomEq
:: (m1 ~ (CustomMethod :: Method f t1), m2 ~ (CustomMethod :: Method f t2))
=> { runCustomEq :: (t1 ~ t2 => m1 :~~: m2) }
-> CustomEq m1 m2
```
```
$ ~/Software/ghc-9.5.20220928/bin/ghc Bug.hs -fforce-recomp
[1 of 1] Compiling Language.LSP.Types.Parsing ( Bug.hs, Bug.o )
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.5.20220928:
ASSERT failed!
in_scope InScope {}
tenv [aJ7 :-> m1_a151]
tenvFVs {m1_a151}
cenv []
cenvFVs {}
tys [b_aJ8]
cos []
Call stack:
CallStack (from HasCallStack):
assertPpr, called at compiler/GHC/Core/TyCo/Subst.hs:683:5 in ghc:GHC.Core.TyCo.Subst
checkValidSubst, called at compiler/GHC/Core/TyCo/Subst.hs:715:29 in ghc:GHC.Core.TyCo.Subst
substTy, called at compiler/GHC/Core/TyCo/Subst.hs:248:43 in ghc:GHC.Core.TyCo.Subst
```9.6.1Simon Peyton JonesRyan ScottSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/22212HEAD-only panic (isUnliftedType) with PatternSynonyms + OverloadedStrings2022-09-21T13:49:04ZRyan ScottHEAD-only panic (isUnliftedType) with PatternSynonyms + OverloadedStrings_(Originally observed in a `head.hackage` CI job [here](https://gitlab.haskell.org/ghc/head.hackage/-/jobs/1173571#L731).)_
GHC HEAD (at commit bd0f418422a3ace8d05c8ce93850190e57321465) panics when building the `what4-1.3` library on Ha..._(Originally observed in a `head.hackage` CI job [here](https://gitlab.haskell.org/ghc/head.hackage/-/jobs/1173571#L731).)_
GHC HEAD (at commit bd0f418422a3ace8d05c8ce93850190e57321465) panics when building the `what4-1.3` library on Hackage. Here is a minimized example:
```hs
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
module Bug where
import qualified Data.ByteString as BS
data Sort = MkSort BS.ByteString [()]
pattern Array :: () -> () -> Sort
pattern Array x y = MkSort "Array" [x,y]
```
This panics when compiled with optimization on HEAD:
```
$ ~/Software/ghc-9.5.20220918/bin/ghc -fforce-recomp Bug.hs -O
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
WARNING:
Simplifier bailing out
Bug, after 4 iterations [58, 28, 31, 3]
Size = {terms: 192, types: 120, coercions: 0, joins: 2/2}
Call stack:
CallStack (from HasCallStack):
warnPprTrace, called at compiler/GHC/Core/Opt/Simplify.hs:192:9 in ghc:GHC.Core.Opt.Simplify
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.5.20220918:
isUnliftedType
r_s1bI :: TYPE rep_s1bH
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:188:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Type.hs:2483:7 in ghc:GHC.Core.Type
isUnliftedType, called at compiler/GHC/Stg/InferTags/Rewrite.hs:220:15 in ghc:GHC.Stg.InferTags.Rewrite
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
But not with GHC 9.4 and earlier:
```
$ ghc-9.4.2 -fforce-recomp Bug.hs -O
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
```9.6.1Andreas Klebingersheafsam.derbyshire@gmail.comAndreas Klebingerhttps://gitlab.haskell.org/ghc/ghc/-/issues/22187ghc panic using SIMD types with unboxed sums2022-12-13T09:31:01ZDavid Orion Girardoghc panic using SIMD types with unboxed sums```haskell
{-# language MagicHash,UnboxedSums #-}
module Test where
import GHC.Prim
foo :: (# Int8X16# | () #) -> ()
foo _ = ()
```
building with `-fllvm` yields:
```
<no location info>: error:
panic! (the 'impossible' happened)
...```haskell
{-# language MagicHash,UnboxedSums #-}
module Test where
import GHC.Prim
foo :: (# Int8X16# | () #) -> ()
foo _ = ()
```
building with `-fllvm` yields:
```
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.4.2:
primRepSlot
No slot for VecRep
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:182:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Types/RepType.hs:329:27 in ghc:GHC.Types.RepType
```
This appears to happen for all SIMD types.
Other combinations of SIMD types (eg in an unboxed tuple) are working fine.9.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/22171GHC 9.2.4 regression: unable to compile test application that worked in 9.2.32022-11-08T07:43:06ZDoug BurkeGHC 9.2.4 regression: unable to compile test application that worked in 9.2.3## Summary
Unable to compile the test-rdfproof executable from swish with GHC 9.2.4 as it appears to just hang. I have built this with many previous versions, including GHC 9.2.3.
I originally reported it to [GHC devs](https://mail.has...## Summary
Unable to compile the test-rdfproof executable from swish with GHC 9.2.4 as it appears to just hang. I have built this with many previous versions, including GHC 9.2.3.
I originally reported it to [GHC devs](https://mail.haskell.org/pipermail/ghc-devs/2022-September/020922.html)
## Steps to reproduce
Unfortunately this is an involved process as I have no idea
- what the problem is
- how to just compile the test executable
### Initial diagnosis by Oleg
Before providing the basic reproduction steps (copied from the email above), @phadej provided [some useful compilation info](https://mail.haskell.org/pipermail/ghc-devs/2022-September/020927.html) which I report below
```
I quickly tried with with {-# OPTIONS_GHC -ddump-timings
-ddump-simpl-trace -ddump-to-file #-} in RDFProofTest.hs and at some
point simplifier does nothing. The simpl-trace file doesn't grow. The
GHC just seems to spin.
After that
- I checked out the `ghc-9.2.4-release` tag,
- built it --flavour=default+profiled_ghc+no_dynamic_ghc
- built the swish using cabal pointing to GHC used (on my machine: cabal
build -w /code/ghc/_build_ghc-9.2/stage1/bin/ghc test-rdfproof -v3)
- copy pasted the command cabal used to execute ghc, which is long, and
added +RTS -xc -RTS there
After that, if I ^C when GHC seems to be spinning, the stack trace is
consistently the same:
^C*** Exception (reporting due to +RTS -xc): (THUNK_STATIC), stack trace:
GHC.Core.Opt.Pipeline.CallArity,
called from GHC.Driver.Main.Core2Core,
called from GHC.Driver.Main.hscSimplify',
called from GHC.Driver.Main.finish,
called from GHC.Driver.Main.hscIncrementalCompile,
called from GHC.Driver.Make.upsweep_mod.compile_it,
called from GHC.Driver.Make.upsweep_mod,
called from GHC.Driver.Make.upsweep.upsweep',
called from GHC.Driver.Make.upsweep,
called from GHC.Driver.Make.withDeferredDiagnostics,
called from GHC.Driver.Make.load'.checkHowMuch,
called from GHC.Driver.Make.load',
called from GHC.Driver.Make.load,
called from GHC.withCleanupSession,
called from GHC.runGhc,
called from GHC.defaultErrorHandler
Hopefully this illustrates how to reproduce with your own GHC.
I also tried with GHC-9.4.1 (using --allow-newer=base) and GHC panics:
[ 6 of 55] Compiling Swish.GraphMatch
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.4.1:
funResultTy
GenLabelMap lb_adrG LabelIndex
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:182:37 in
ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Type.hs:1334:49 in
ghc:GHC.Core.Type
GHC-9.4.2 panics in the same way.
Maybe these failures are related?
- Oleg
```
### Download the code
I am on a linux machine (ubuntu 22.04) and have seen this with builds
either with stack or nix.
```
% git clone https://gitlab.com/dburke/swish temp
% cd temp
% git rev-parse HEAD
09c92e0fbbea9be86cac5c8e273e1d5915a9eeae
```
Added to get the timings, but it's not strictly necessary:
```
% sed -i -e "s/-Wall /-Wall -ddump-timings /" swish.cabal
```
### building with stack
If you try with `--resolver lts-19.22` (ghc 9.0.2) then it works. With GHC 9.2.4 it fails:
```
% stack test --resolver nightly-2022-09-05 :test-rdfproof
...
*** Parser [Main]:
Parser [Main]: alloc=24346008 time=8.730
*** Renamer/typechecker [Main]:
Renamer/typechecker [Main]: alloc=58415776 time=44.077
*** Desugar [Main]:
Desugar [Main]: alloc=22148416 time=15.693
*** Simplifier [Main]:
Simplifier [Main]: alloc=651048904 time=530.123
*** Specialise [Main]:
Specialise [Main]: alloc=44412080 time=31.885
*** Float out(FOS {Lam = Just 0,
Consts = True,
OverSatApps = False}) [Main]:
Float out(FOS {Lam = Just 0, Consts = True, OverSatApps = False})
[Main]: alloc=207753368 time=259.238
*** Simplifier [Main]:
Simplifier [Main]: alloc=599788216 time=548.107
*** Simplifier [Main]:
Simplifier [Main]: alloc=562910904 time=474.847
*** Simplifier [Main]:
Simplifier [Main]: alloc=725093584 time=643.255
Float inwards [Main]: alloc=23720 time=0.011
Called arity analysis [Main]: alloc=25856 time=0.012
*** Float inwards [Main]:
*** Called arity analysis [Main]:
*** Simplifier [Main]:
```
At this point it just makes my laptop fan spin faster wit h one of my
CPUs pegged at 100%, but it never seems to print anything more.
### building with nix
This works
```
% nix-shell --argstr compiler ghc923
% cabal test test-rdfproof
```
With 9.2.4 you get similar to above (the screen messages don't quite agree):
```
% nix-shell --argstr compiler ghc924
cabal test test-rdfproof
Warning: The package list for 'hackage.haskell.org' is 20 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
Build profile: -w ghc-9.2.4 -O1
In order, the following will be built (use -v for more details):
- swish-0.10.2.0 (test:test-rdfproof) (first run)
Preprocessing test suite 'test-rdfproof' for swish-0.10.2.0..
Building test suite 'test-rdfproof' for swish-0.10.2.0..
*** initializing unit database:
initializing unit database: alloc=7389248 time=4.462
*** initializing unit database:
initializing unit database: alloc=4001312 time=11.664
*** Chasing dependencies:
*** systool:cpp:
systool:cpp: alloc=319464 time=0.481
Chasing dependencies: alloc=12861208 time=6.331
[2 of 2] Compiling Main ( tests/RDFProofTest.hs,
/home/dburke/rdf/temp/dist-newstyle/build/x86_64-linux/ghc-9.2.4/swish-0.10.2.0/t/test-rdfproof/build/test-rdfproof/test-rdfproof-tmp/Main.o
)
*** Parser [Main]:
Parser [Main]: alloc=25236056 time=23.982
*** Renamer/typechecker [Main]:
Renamer/typechecker [Main]: alloc=101830968 time=97.529
*** Desugar [Main]:
Desugar [Main]: alloc=24617072 time=19.187
*** Simplifier [Main]:
Simplifier [Main]: alloc=665051592 time=558.078
*** Specialise [Main]:
Specialise [Main]: alloc=44894576 time=30.341
*** Float out(FOS {Lam = Just 0,
Consts = True,
OverSatApps = False}) [Main]:
Float out(FOS {Lam = Just 0, Consts = True, OverSatApps = False})
[Main]: alloc=208060752 time=245.458
*** Simplifier [Main]:
Simplifier [Main]: alloc=602721856 time=555.073
*** Simplifier [Main]:
Simplifier [Main]: alloc=563887832 time=529.865
*** Simplifier [Main]:
Simplifier [Main]: alloc=727381840 time=606.367
*** Float inwards [Main]:
Float inwards [Main]: alloc=23720 time=0.012
*** Called arity analysis [Main]:
Called arity analysis [Main]: alloc=25848 time=0.012
*** Simplifier [Main]:
```
and here it hangs.
## Expected behavior
To compile the program.
## Environment
* GHC version used: 9.2.4
Optional:
* Operating System: linux
* System Architecture: x86_64-linux9.2.5Matthew PickeringMatthew Pickeringhttps://gitlab.haskell.org/ghc/ghc/-/issues/22114Core Lint error when building Agda-2.6.2.2 with HEAD (idArity 3 exceeds typeA...2022-10-26T10:08:28ZRyan ScottCore Lint error when building Agda-2.6.2.2 with HEAD (idArity 3 exceeds typeArity 1)_(Originally observed in a `head.hackage` CI job [here](https://gitlab.haskell.org/ghc/head.hackage/-/jobs/1157509#L1).)_
The `Agda-2.6.2.2` library on Hackage fails to compile with HEAD (at commit 161a6f1fd62e797e978e7808a5f567fefa123f..._(Originally observed in a `head.hackage` CI job [here](https://gitlab.haskell.org/ghc/head.hackage/-/jobs/1157509#L1).)_
The `Agda-2.6.2.2` library on Hackage fails to compile with HEAD (at commit 161a6f1fd62e797e978e7808a5f567fefa123f16) when combined with `-O` and `-dcore-lint`. Here is a minimized example:
```hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE Haskell2010 #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Agda.TypeChecking.Serialise.Instances.Common (EmbPrj(..)) where
import Control.Monad.Except (ExceptT, throwError)
import Data.Array.IArray (Array, (!))
import Data.Int (Int32)
import Data.Kind (Constraint, Type)
import qualified Data.Map as M (Map, insert, lookup)
import Data.Proxy (Proxy(..))
import Data.Typeable (Typeable, TypeRep, typeRep, cast)
import Control.Monad.State.Strict (StateT, gets, modify)
class Typeable a => EmbPrj a where
value :: Int32 -> R a
instance EmbPrj Bool where
value = vcase valu where
valu [] = valuN True
valu [0] = valuN False
valu _ = malformed
type family If (b :: Bool) (l :: k) (r :: k) :: k where
If 'True l r = l
If 'False l r = r
type family All (p :: k -> Constraint) (as :: [k]) :: Constraint where
All p '[] = ()
All p (a ': as) = (p a, All p as)
type family Foldr (c :: k -> l -> l) (n :: l) (as :: [k]) :: l where
Foldr c n '[] = n
Foldr c n (a ': as) = c a (Foldr c n as)
type family Foldr' (c :: Function k (Function l l -> Type) -> Type)
(n :: l) (as :: [k]) :: l where
Foldr' c n '[] = n
Foldr' c n (a ': as) = Apply (Apply c a) (Foldr' c n as)
type family Map (f :: Function k l -> Type) (as :: [k]) :: [l] where
Map f as = Foldr' (ConsMap0 f) '[] as
data ConsMap0 :: (Function k l -> Type) -> Function k (Function [l] [l] -> Type) -> Type
data ConsMap1 :: (Function k l -> Type) -> k -> Function [l] [l] -> Type
type instance Apply (ConsMap0 f) a = ConsMap1 f a
type instance Apply (ConsMap1 f a) tl = Apply f a ': tl
type family Constant (b :: l) (as :: [k]) :: [l] where
Constant b as = Map (Constant1 b) as
type Arrows (as :: [Type]) (r :: Type) = Foldr (->) r as
type Products (as :: [Type]) = Foldr (,) () as
type family IsBase (t :: Type) :: Bool where
IsBase (a -> t) = 'False
IsBase a = 'True
type family Domains (t :: Type) :: [Type] where
Domains t = If (IsBase t) '[] (Domains' t)
type family Domains' (t :: Type) :: [Type] where
Domains' (a -> t) = a ': Domains t
type family CoDomain (t :: Type) :: Type where
CoDomain t = If (IsBase t) t (CoDomain' t)
type family CoDomain' (t :: Type) :: Type where
CoDomain' (a -> t) = CoDomain t
class Currying as b where
uncurrys :: Proxy as -> Proxy b -> Arrows as b -> Products as -> b
currys :: Proxy as -> Proxy b -> (Products as -> b) -> Arrows as b
instance Currying '[] b where
uncurrys _ _ f = \ () -> f
currys _ _ f = f ()
instance Currying as b => Currying (a ': as) b where
uncurrys _ p f = uncurry $ uncurrys (Proxy :: Proxy as) p . f
currys _ p f = currys (Proxy :: Proxy as) p . curry f
data Function :: Type -> Type -> Type
data Constant0 :: Function a (Function b a -> Type) -> Type
data Constant1 :: Type -> Function b a -> Type
type family Apply (t :: Function k l -> Type) (u :: k) :: l
type instance Apply Constant0 a = Constant1 a
type instance Apply (Constant1 a) b = a
type Node = [Int32]
type Table k v = M.Map k v
data U = forall a . Typeable a => U !a
type Memo = Table (Int32, TypeRep) U
data St = St
{ nodeE :: !(Array Int32 Node)
, nodeMemo :: !Memo
}
data TypeError = GenericError String
type R a = ExceptT TypeError (StateT St IO) a
malformed :: R a
malformed = throwError $ GenericError "Malformed input."
{-# INLINE vcase #-}
vcase :: forall a . EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase valu = \ix -> do
memo <- gets nodeMemo
let aTyp = typeRep (Proxy :: Proxy a)
let maybeU = M.lookup (ix, aTyp) memo
case maybeU of
Just (U u) -> maybe malformed return (cast u)
Nothing -> do
v <- valu . (! ix) =<< gets nodeE
modify $ \s -> s { nodeMemo = M.insert (ix, aTyp) (U v) memo }
return v
class VALU t b where
valuN' :: b ~ IsBase t =>
All EmbPrj (Domains t) =>
t -> Products (Constant Int32 (Domains t)) -> R (CoDomain t)
instance VALU t 'True where
valuN' c () = return c
{-# INLINE valuN #-}
valuN :: forall t. VALU t (IsBase t) =>
Currying (Constant Int32 (Domains t)) (R (CoDomain t)) =>
All EmbPrj (Domains t) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN f = currys (Proxy :: Proxy (Constant Int32 (Domains t)))
(Proxy :: Proxy (R (CoDomain t)))
(valuN' f)
```
With GHC 9.4 and earlier, this GHC invocation succeeds:
```
$ ghc-9.4 Bug.hs -fforce-recomp -dcore-lint -O
[1 of 1] Compiling Agda.TypeChecking.Serialise.Instances.Common ( Bug.hs, Bug.o )
```
With HEAD, however, this produces a Core Lint error:
```
$ ~/Software/ghc-9.5.20220827/bin/ghc Bug.hs -fforce-recomp -dcore-lint -O
[1 of 1] Compiling Agda.TypeChecking.Serialise.Instances.Common ( Bug.hs, Bug.o )
*** Core Lint errors : in result of Simplifier ***
<no location info>: warning:
idArity 3 exceeds typeArity 1: fail_d26u
In the RHS of valu_s2B8 :: [Int32]
-> Foldr
(->)
(ExceptT TypeError (StateT St IO) (CoDomain Bool))
(Constant Int32 (Domains Bool))
In the body of lambda with binder ds_d26j :: [Int32]
Substitution: <InScope = {}
IdSubst = []
TvSubst = []
CvSubst = []>
```
The full Core Lint error is quite long, so I've attached it separately here: [agda-core-lint-error.txt](/uploads/96d5a092c226113975667dd4ed89c947/agda-core-lint-error.txt)9.6.1Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/22002GHC 9.0.2 panics when building Adga 2.6.2.2 on i386 and mipsel2023-08-01T17:27:01ZScott TalbertGHC 9.0.2 panics when building Adga 2.6.2.2 on i386 and mipsel## Summary
GHC 9.0.2 panics when building Adga 2.6.2.2 on i386 and mipsel architectures (both 32-bit)
```
[345 of 401] Compiling Agda.TypeChecking.Rules.Term ( src/full/Agda/TypeChecking/Rules/Term.hs, dist-ghc/build/Agda/TypeChecking/...## Summary
GHC 9.0.2 panics when building Adga 2.6.2.2 on i386 and mipsel architectures (both 32-bit)
```
[345 of 401] Compiling Agda.TypeChecking.Rules.Term ( src/full/Agda/TypeChecking/Rules/Term.hs, dist-ghc/build/Agda/TypeChecking/Rules/Term.o, dist-ghc/build/Agda/TypeChecking/Rules/Term.dyn_o )
ghc: panic! (the 'impossible' happened)
(GHC version 9.0.2:
applyTypeToArgs
Expression: lambdaAnnotationCheck13
ds18_s6rOs checkTacticAttribute_s ds20_s6rOu
Type: Addr#
Args: [ds18_s6rOs, checkTacticAttribute_s, ds20_s6rOu]
Args': [ds18_s6rOs, checkTacticAttribute_s, ds20_s6rOu]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Outputable.hs:1230:37 in ghc:GHC.Utils.Outputable
pprPanic, called at compiler/GHC/Core/Utils.hs:276:17 in ghc:GHC.Core.Utils
```
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
The full logs are available here:
https://buildd.debian.org/status/fetch.php?pkg=agda&arch=i386&ver=2.6.2.2-1&stamp=1659812412&raw=0
https://buildd.debian.org/status/fetch.php?pkg=agda&arch=mipsel&ver=2.6.2.2-1&stamp=1659816519&raw=0
## Steps to reproduce
Try to build Agda 2.6.2.2 with GHC 9.0.2.
## Expected behavior
Build completes successfully.
## Environment
* GHC version used: 9.0.2
Optional:
* Operating System: Debian Unstable
* System Architecture: i386, mipsel9.10.1https://gitlab.haskell.org/ghc/ghc/-/issues/21896Panic when checking type family dependency2022-07-26T07:49:55ZGergő ÉrdiPanic when checking type family dependency```
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DataKinds, TypeFamilies, TypeFamilyDependencies, PolyKinds #-}
module Bug where
data T = Foo | Bar
type family F (ns :: T) (ret :: k) = (r :: k) | r -> ret where
F Foo r = r
F...```
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DataKinds, TypeFamilies, TypeFamilyDependencies, PolyKinds #-}
module Bug where
data T = Foo | Bar
type family F (ns :: T) (ret :: k) = (r :: k) | r -> ret where
F Foo r = r
F Bar r = r
```
On a GHC as of e2f0094c315746ff15b8d9650cf318f81d8416d7, with sufficient sanity checks (i.e. compiled with `-DDEBUG`), this crashes with:
```
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.5.20220719:
ASSERT failed!
in_scope InScope {r_a9 k_aJ}
tenv [a9 :-> r_a9, aa :-> r_a9, aJ :-> k_aJ]
cenv []
tys [k_aN, r_aa]
cos []
needInScope {k_aN}
Call stack:
CallStack (from HasCallStack):
assertPpr, called at compiler/GHC/Core/TyCo/Subst.hs:645:5 in ghc:GHC.Core.TyCo.Subst
checkValidSubst, called at compiler/GHC/Core/TyCo/Subst.hs:694:17 in ghc:GHC.Core.TyCo.Subst
substTys, called at compiler/GHC/Core/FamInstEnv.hs:568:25 in ghc:GHC.Core.FamInstEnv
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```https://gitlab.haskell.org/ghc/ghc/-/issues/21888HEAD fails to compile MemoTrie-0.6.10 due to stack space overflow2022-07-25T16:06:02ZRyan ScottHEAD fails to compile MemoTrie-0.6.10 due to stack space overflow_(Originally noticed in a `head.hackage` job [here](https://gitlab.haskell.org/ghc/head.hackage/-/jobs/1117128#L3125).)_
The `MemoTrie-0.6.10` library on Hackage fails to compile on GHC HEAD (at commit e2f0094c315746ff15b8d9650cf318f81d..._(Originally noticed in a `head.hackage` job [here](https://gitlab.haskell.org/ghc/head.hackage/-/jobs/1117128#L3125).)_
The `MemoTrie-0.6.10` library on Hackage fails to compile on GHC HEAD (at commit e2f0094c315746ff15b8d9650cf318f81d8416d7). Here is a minimized example:
```hs
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module Data.MemoTrie (HasTrie(..)) where
import Control.Arrow (Arrow(first))
import Data.Bits (Bits((.|.), shiftL))
import Data.Kind (Type)
infixr 0 :->:
class HasTrie a where
data (:->:) a :: Type -> Type
enumerate :: (a :->: b) -> [(a,b)]
instance HasTrie () where
newtype () :->: a = UnitTrie a
enumerate (UnitTrie a) = [((),a)]
instance HasTrie Bool where
data Bool :->: x = BoolTrie x x
enumerate (BoolTrie f t) = [(False,f),(True,t)]
instance (HasTrie a, HasTrie b) => HasTrie (Either a b) where
data (Either a b) :->: x = EitherTrie (a :->: x) (b :->: x)
enumerate (EitherTrie s t) = enum' Left s `weave` enum' Right t
enum' :: (HasTrie a) => (a -> a') -> (a :->: b) -> [(a', b)]
enum' f = (fmap.first) f . enumerate
weave :: [a] -> [a] -> [a]
[] `weave` as = as
as `weave` [] = as
(a:as) `weave` bs = a : (bs `weave` as)
instance (HasTrie a, HasTrie b) => HasTrie (a,b) where
newtype (a,b) :->: x = PairTrie (a :->: (b :->: x))
enumerate (PairTrie tt) =
[ ((a,b),x) | (a,t) <- enumerate tt , (b,x) <- enumerate t ]
instance HasTrie x => HasTrie [x] where
newtype [x] :->: a = ListTrie (Either () (x,[x]) :->: a)
enumerate (ListTrie t) = enum' list t
list :: Either () (x,[x]) -> [x]
list = either (const []) (uncurry (:))
unbit :: Num t => Bool -> t
unbit False = 0
unbit True = 1
unbits :: (Num t, Bits t) => [Bool] -> t
unbits [] = 0
unbits (x:xs) = unbit x .|. shiftL (unbits xs) 1
instance HasTrie Integer where
newtype Integer :->: a = IntegerTrie ((Bool,[Bool]) :->: a)
enumerate (IntegerTrie t) = enum' unbitsZ t
unbitsZ :: (Num n, Bits n) => (Bool,[Bool]) -> n
unbitsZ (positive,bs) = sig (unbits bs)
where
sig | positive = id
| otherwise = negate
```
If you compile this with optimizations with GHC 9.2 and earlier, it succeeds:
```
$ ghc-9.2.3 MemoTrie.hs -fforce-recomp -O
[1 of 1] Compiling Data.MemoTrie ( MemoTrie.hs, MemoTrie.o )
```
If you compile with HEAD, however, it fails with:
```
$ ~/Software/ghc-9.5.20220719/bin/ghc MemoTrie.hs -fforce-recomp -O
[1 of 1] Compiling Data.MemoTrie ( MemoTrie.hs, MemoTrie.o )
ghc-9.5.20220719: Stack space overflow: current size 33624 bytes.
ghc-9.5.20220719: Use `+RTS -Ksize -RTS' to increase it.
```9.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/21827panic: Prelude.chr: bad argument on GHC 8.6.52022-07-12T14:07:20ZLeandro Rodriguez Llosapanic: Prelude.chr: bad argument on GHC 8.6.5## Environment
* GHC version used: GHC 9.0.2
* Stack version used: 2.7.5
* System Architecture: x86_64
* Operating System: Arch Linux
## Summary
I was trying to set up my development environment, the VSCode extensions, but I couldn't.
...## Environment
* GHC version used: GHC 9.0.2
* Stack version used: 2.7.5
* System Architecture: x86_64
* Operating System: Arch Linux
## Summary
I was trying to set up my development environment, the VSCode extensions, but I couldn't.
## Steps to reproduce
```zsh
git clone https://github.com/haskell/haskell-ide-engine --recurse-submodules
cd haskell-ide-engine
stack ./install.hs hie-9.0.2
```
Something was wrong..
```zsh
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.5 for x86_64-unknown-linux):
Prelude.chr: bad argument: 1526726659
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
-- While building simple Setup.hs (scroll up to its section to see the error) using:
/home/leandro/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/bin/ghc-8.6.5 -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-2.4.0.1 /home/leandro/.stack/setup-exe-src/setup-mPHDZzAJ.hs /home/leandro/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -o /home/leandro/.stack/setup-exe-cache/x86_64-linux-tinfo6/tmp-Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5
Process exited with code: ExitFailure 1
```
Then, I so I went to /home/leandro/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/bin directory, and opened the ghc-8.6.5 script. This is the script:
```sh
#!/bin/sh
exedir="/home/leandro/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/bin"
exeprog="ghc-stage2"
executablename="$exedir/$exeprog"
datadir="/home/leandro/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/share"
bindir="/home/leandro/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/bin"
topdir="/home/leandro/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5"
executablename="$exedir/ghc"
exec "$executablename" -B"$topdir" ${1+"$@"}
```
The binaries in this directory are:
* ghc
* ghc-iserv-dyn
* ghc-pkg
* haddock
* hpc
* runghc
* ghc-iserv
* ghc-iserv-prof
* ghc-split
* hp2ps
* hsc2hs
* unlit
But there is no executable `exeprog="ghc-stage2"`, so I don't know what to do at this point, I need help.