GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2022-05-20T09:55:47Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/21130mkCoCast panic in 9.22022-05-20T09:55:47ZKrzysztof GogolewskimkCoCast panic in 9.2The following file causes a panic in 9.2.1 and on the `ghc-9.2` branch
```haskell
{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
module M where
type family Item l
type instance Item [a] = a
f :: Enum (Item l) => l
f = f
x = (_ f) ::...The following file causes a panic in 9.2.1 and on the `ghc-9.2` branch
```haskell
{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
module M where
type family Item l
type instance Item [a] = a
f :: Enum (Item l) => l
f = f
x = (_ f) :: Int
```
```
(GHC version 9.2.0.20220224:
mkCoCast
(Enum (Sym (D:R:Item[][0] <Char>_N)))_R
Enum Char ~ Enum (Item [Char])
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/Coercion.hs:1675:5 in ghc:GHC.Core.Coercion
```
HEAD is good:
```
M.hs:10:6: error:
• Found hole: _ :: t0 -> Int
Where: ‘t0’ is an ambiguous type variable
```
I haven't checked which commit fixed it. There are no other tickets mentioning `mkCoCast`, so I think it's worth checking if the bug is actually fixed or merely hidden.
Credits to Dominic Steinitz for the initial report.9.2.2Ben Gamarisheafsam.derbyshire@gmail.comBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/19417Segfault in GC in GHC 8.10.{3,4}2022-05-09T15:58:18ZadamSegfault in GC in GHC 8.10.{3,4}## Summary
A bunch of segfaults:
```
ghc:w[92225]: segfault at 40df5c48 ip 000000000040b245 sp 00007fe3d97fca90 error 4 in ghc[400000+3715000]
ghc:w[94312]: segfault at 45131c48 ip 000000000040b245 sp 00007f68a2bfda90 error 4 in ghc[40...## Summary
A bunch of segfaults:
```
ghc:w[92225]: segfault at 40df5c48 ip 000000000040b245 sp 00007fe3d97fca90 error 4 in ghc[400000+3715000]
ghc:w[94312]: segfault at 45131c48 ip 000000000040b245 sp 00007f68a2bfda90 error 4 in ghc[400000+3715000]
ghc:w[31098]: segfault at 40106938 ip 000000000040b3b5 sp 00007fc1557fca90 error 4 in ghc[400000+36df000]
ghc:w[42775]: segfault at 408eb9e0 ip 000000000040b3b5 sp 00007f8536bfda90 error 4 in ghc[400000+36df000]
ghc:w[44907]: segfault at 414699e0 ip 000000000040b3b5 sp 00007f01c7ffea90 error 4 in ghc[400000+36df000]
ghc:w[49393]: segfault at 40743808 ip 000000000040b3b5 sp 00007ff38bffea90 error 4 in ghc[400000+36df000]
ghc:w[62845]: segfault at 43c089e0 ip 000000000040b3b5 sp 00007f18aebfda90 error 4 in ghc[400000+36df000]
```
```
$ addr2line -e .../lib/ghc-8.10.4/bin/ghc 000000000040b3b5
.../rts/sm/Evac.c:686
$ addr2line -e .../lib/ghc-8.10.4/bin/ghc 000000000040b245
.../rts/sm/Evac.c:445
```
On 8.10.3 we've also saw it happen in `rts/sm/Evac.c:839`
## Steps to reproduce
Building ghcide 0.7.3.0 (library):
```
runhaskell Setup configure \
# ... package db flags
--enable-debug-info \
--disable-library-stripping \
--disable-library-for-ghci \
--ghc-option=-j \
--enable-shared \
--enable-library-profiling \
runhaskell Setup build \
--verbose=2 \
--ghc-option=-Wno-deprecated-flags \
--ghc-option=-haddock \
'--ghc-options=+RTS -A128M -n4m -RTS'
```
The `build` command fails while building the main library. It does not happen every time. If I remove cabal's `--enable-shared` (implying GHC's `-dynamic-too`) it does not happen.
## Environment
* GHC version used: 8.10.3 and 8.10.4. GHC is built with `DYNAMIC_GHC_PROGRAMS=NO` and `GhcStage2HcOpts+=-eventlog`.
Optional:
* Operating System: redhat linux
* System Architecture: x86_64https://gitlab.haskell.org/ghc/ghc/-/issues/17723Using default methods with (r ~ LiftedRep) leads to Iface Lint failure2022-05-07T21:02:22ZRyan ScottUsing default methods with (r ~ LiftedRep) leads to Iface Lint failureI originally spotted this bug when trying to minimize #17722, but I believe this is an entirely different bug.
See also #19519, which makes this bug show up much more often: every use of `liftTyped`.
To reproduce the issue, you'll nee...I originally spotted this bug when trying to minimize #17722, but I believe this is an entirely different bug.
See also #19519, which makes this bug show up much more often: every use of `liftTyped`.
To reproduce the issue, you'll need these two files:
```hs
-- Lib.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
module Lib (C(..)) where
import GHC.Exts
-- Essentially a stripped-down version of the `Lift` type class from
-- Language.Haskell.TH.Syntax. I have redefined it here both to strip away
-- inessential details and to ensure that this test case will not change if
-- the API of Lift were to change in the future.
class C (a :: TYPE (r :: RuntimeRep)) where
m :: a -> ()
default m :: (r ~ LiftedRep) => a -> ()
m = const ()
```
```hs
-- Bug.hs
module Bug where
import Lib
data Foo
instance C Foo
```
Next, compile them with a recent version of GHC like so:
```
$ /opt/ghc/8.8.2/bin/ghc -c Lib.hs -O -dcore-lint && /opt/ghc/8.8.2/bin/ghc -c Bug.hs -O -dcore-lint
ghc: panic! (the 'impossible' happened)
(GHC version 8.8.2 for x86_64-unknown-linux):
Iface Lint failure
In interface for Lib
Unfolding of $dmm
<no location info>: warning:
In the type ‘(a_a1a9 |> Sym (TYPE (Sym co_a1ac))_N) -> ()’
co_a1ac :: r_a1a8 ~# 'LiftedRep
[LclId[CoVarId]] is out of scope
$dmm = \ (@ (r_a1a8 :: RuntimeRep))
(@ (a_a1a9 :: TYPE r_a1a8))
($dC_a1aa :: C a_a1a9)
($d~_a1ab :: r_a1a8 ~ 'LiftedRep) ->
case eq_sel @ RuntimeRep @ r_a1a8 @ 'LiftedRep $d~_a1ab of co_a1ac
{ __DEFAULT ->
\ (ds_a1ad :: (a_a1a9 |> Sym (TYPE (Sym co_a1ac))_N)) -> ()
}
Iface expr = \ @ r :: RuntimeRep
@ a :: TYPE r
($dC :: C a)
($d~ :: r ~ 'LiftedRep) ->
case eq_sel @ RuntimeRep @ r @ 'LiftedRep $d~ of co { DEFAULT ->
\ (ds :: (a |> Sym (TYPE (Sym co))_N)) -> () }
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable
pprPanic, called at compiler/iface/TcIface.hs:1546:33 in ghc:TcIface
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
I have observed this panic on every version of GHC from 8.2.2 to HEAD.
Another strange thing about this program is that I have to write `m = const ()`. If I instead try to define it like `m _ = ()`, I get the following error:
```
$ /opt/ghc/8.8.2/bin/ghc -c Lib.hs -O -dcore-lint && /opt/ghc/8.8.2/bin/ghc -c Bug.hs -O -dcore-lint
Lib.hs:19:5: error:
A levity-polymorphic type is not allowed here:
Type: a
Kind: TYPE r
In a wildcard pattern
|
19 | m _ = ()
| ^
```
This seems suspicious, does it not? Why should that binder get rejected for being levity polymorphic if `r ~ LiftedRep`? Shouldn't that make the binder levity monomorphic?9.2.2https://gitlab.haskell.org/ghc/ghc/-/issues/7094Irrefutable pattern failed for pattern Data.Maybe.Just2022-04-29T10:39:00ZpganelinIrrefutable pattern failed for pattern Data.Maybe.JustThe following invalid program causes ghc panic
```
-----------------------
--State-Monad.hs
data Term = Con Int
| Div Term Term
deriving (Show)
type M a = State -> (a,State)
type State =Int
instance Monad Int -> (a,Int) wh...The following invalid program causes ghc panic
```
-----------------------
--State-Monad.hs
data Term = Con Int
| Div Term Term
deriving (Show)
type M a = State -> (a,State)
type State =Int
instance Monad Int -> (a,Int) where
g >>= f = undefined
return = undefined
-------------------------------
```
```
D:\>"C:\Free\Haskell Platform\2012.2.0.0\bin\ghc.exe" D:\State-Monad.hs
[1 of 1] Compiling Main ( D:\State-Monad.hs, D:\State-Monad.o )
ghc.exe: panic! (the 'impossible' happened)
(GHC version 7.4.1 for i386-unknown-mingw32):
compiler\rename\RnSource.lhs:429:14-81: Irrefutable pattern failed for pattern Data.Maybe.Just (inst_tyvars,
_,
SrcLoc.L _ cls,
_)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```7.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/10187Panic: RegAlloc.Liveness.computeLivenss; SCCs aren't in reverse dependent ord...2022-04-27T07:40:10ZMiëtek BakPanic: RegAlloc.Liveness.computeLivenss; SCCs aren't in reverse dependent order; bad blockId c8xHdI’ve found another instance of the elusive `RegAlloc.Liveness.computeLivenss` bug, by attempting to bootstrap *cabal-install* 1.20.0.6 with GHC 7.8.4 on 32-bit CentOS 6, released on 27/05/2013 (available on [Amazon EC2](https://aws.amazo...I’ve found another instance of the elusive `RegAlloc.Liveness.computeLivenss` bug, by attempting to bootstrap *cabal-install* 1.20.0.6 with GHC 7.8.4 on 32-bit CentOS 6, released on 27/05/2013 (available on [Amazon EC2](https://aws.amazon.com/marketplace/pp/B00A6KZBC6/)).
Unfortunately, I’m unable to reproduce the bug on a subsequent attempt. Cosmic rays?
```
Configuring text-1.1.0.1...
Building text-1.1.0.1...
Preprocessing library text-1.1.0.1...
[ 1 of 43] Compiling Data.Text.Internal.Read ( Data/Text/Internal/Read.hs, dist/build/Data/Text/Internal/Read.o )
[ 2 of 43] Compiling Data.Text.Internal.Encoding.Utf32 ( Data/Text/Internal/Encoding/Utf32.hs, dist/build/Data/Text/Internal/Encoding/Utf32.o )
[ 3 of 43] Compiling Data.Text.Internal.Fusion.Size ( Data/Text/Internal/Fusion/Size.hs, dist/build/Data/Text/Internal/Fusion/Size.o )
[ 4 of 43] Compiling Data.Text.Internal.Builder.RealFloat.Functions ( Data/Text/Internal/Builder/RealFloat/Functions.hs, dist/build/Data/Text/Internal/Builder/RealFloat/Functions.o )
[ 5 of 43] Compiling Data.Text.Internal.Builder.Int.Digits ( Data/Text/Internal/Builder/Int/Digits.hs, dist/build/Data/Text/Internal/Builder/Int/Digits.o )
[ 6 of 43] Compiling Data.Text.Internal.Fusion.Types ( Data/Text/Internal/Fusion/Types.hs, dist/build/Data/Text/Internal/Fusion/Types.o )
[ 7 of 43] Compiling Data.Text.Internal.Fusion.CaseMapping ( Data/Text/Internal/Fusion/CaseMapping.hs, dist/build/Data/Text/Internal/Fusion/CaseMapping.o )
[ 8 of 43] Compiling Data.Text.Encoding.Error ( Data/Text/Encoding/Error.hs, dist/build/Data/Text/Encoding/Error.o )
[ 9 of 43] Compiling Data.Text.Internal.Unsafe.Shift ( Data/Text/Internal/Unsafe/Shift.hs, dist/build/Data/Text/Internal/Unsafe/Shift.o )
[10 of 43] Compiling Data.Text.Internal.Encoding.Utf16 ( Data/Text/Internal/Encoding/Utf16.hs, dist/build/Data/Text/Internal/Encoding/Utf16.o )
[11 of 43] Compiling Data.Text.Internal.Functions ( Data/Text/Internal/Functions.hs, dist/build/Data/Text/Internal/Functions.o )
[12 of 43] Compiling Data.Text.Internal.Unsafe ( Data/Text/Internal/Unsafe.hs, dist/build/Data/Text/Internal/Unsafe.o )
[13 of 43] Compiling Data.Text.Internal.Fusion.Common ( Data/Text/Internal/Fusion/Common.hs, dist/build/Data/Text/Internal/Fusion/Common.o )
[14 of 43] Compiling Data.Text.Array ( Data/Text/Array.hs, dist/build/Data/Text/Array.o )
[15 of 43] Compiling Data.Text.Internal.Unsafe.Char ( Data/Text/Internal/Unsafe/Char.hs, dist/build/Data/Text/Internal/Unsafe/Char.o )
[16 of 43] Compiling Data.Text.Internal ( Data/Text/Internal.hs, dist/build/Data/Text/Internal.o )
[17 of 43] Compiling Data.Text.Unsafe ( Data/Text/Unsafe.hs, dist/build/Data/Text/Unsafe.o )
[18 of 43] Compiling Data.Text.Internal.Private ( Data/Text/Internal/Private.hs, dist/build/Data/Text/Internal/Private.o )
[19 of 43] Compiling Data.Text.Internal.Fusion ( Data/Text/Internal/Fusion.hs, dist/build/Data/Text/Internal/Fusion.o )
[20 of 43] Compiling Data.Text.Internal.Encoding.Fusion.Common ( Data/Text/Internal/Encoding/Fusion/Common.hs, dist/build/Data/Text/Internal/Encoding/Fusion/Common.o )
[21 of 43] Compiling Data.Text.Internal.Encoding.Utf8 ( Data/Text/Internal/Encoding/Utf8.hs, dist/build/Data/Text/Internal/Encoding/Utf8.o )
[22 of 43] Compiling Data.Text.Internal.Encoding.Fusion ( Data/Text/Internal/Encoding/Fusion.hs, dist/build/Data/Text/Internal/Encoding/Fusion.o )
[23 of 43] Compiling Data.Text.Internal.Lazy.Encoding.Fusion ( Data/Text/Internal/Lazy/Encoding/Fusion.hs, dist/build/Data/Text/Internal/Lazy/Encoding/Fusion.o )
[24 of 43] Compiling Data.Text.Internal.Search ( Data/Text/Internal/Search.hs, dist/build/Data/Text/Internal/Search.o )
[25 of 43] Compiling Data.Text ( Data/Text.hs, dist/build/Data/Text.o )
[26 of 43] Compiling Data.Text.Encoding ( Data/Text/Encoding.hs, dist/build/Data/Text/Encoding.o )
[27 of 43] Compiling Data.Text.Foreign ( Data/Text/Foreign.hs, dist/build/Data/Text/Foreign.o )
[28 of 43] Compiling Data.Text.Internal.IO ( Data/Text/Internal/IO.hs, dist/build/Data/Text/Internal/IO.o )
[29 of 43] Compiling Data.Text.IO ( Data/Text/IO.hs, dist/build/Data/Text/IO.o )
[30 of 43] Compiling Data.Text.Internal.Lazy ( Data/Text/Internal/Lazy.hs, dist/build/Data/Text/Internal/Lazy.o )
[31 of 43] Compiling Data.Text.Internal.Lazy.Fusion ( Data/Text/Internal/Lazy/Fusion.hs, dist/build/Data/Text/Internal/Lazy/Fusion.o )
[32 of 43] Compiling Data.Text.Internal.Lazy.Search ( Data/Text/Internal/Lazy/Search.hs, dist/build/Data/Text/Internal/Lazy/Search.o )
[33 of 43] Compiling Data.Text.Lazy.Internal ( Data/Text/Lazy/Internal.hs, dist/build/Data/Text/Lazy/Internal.o )
[34 of 43] Compiling Data.Text.Lazy ( Data/Text/Lazy.hs, dist/build/Data/Text/Lazy.o )
[35 of 43] Compiling Data.Text.Internal.Builder ( Data/Text/Internal/Builder.hs, dist/build/Data/Text/Internal/Builder.o )
[36 of 43] Compiling Data.Text.Lazy.Builder ( Data/Text/Lazy/Builder.hs, dist/build/Data/Text/Lazy/Builder.o )
[37 of 43] Compiling Data.Text.Internal.Builder.Functions ( Data/Text/Internal/Builder/Functions.hs, dist/build/Data/Text/Internal/Builder/Functions.o )
[38 of 43] Compiling Data.Text.Lazy.Builder.Int ( Data/Text/Lazy/Builder/Int.hs, dist/build/Data/Text/Lazy/Builder/Int.o )
[39 of 43] Compiling Data.Text.Lazy.IO ( Data/Text/Lazy/IO.hs, dist/build/Data/Text/Lazy/IO.o )
[40 of 43] Compiling Data.Text.Lazy.Read ( Data/Text/Lazy/Read.hs, dist/build/Data/Text/Lazy/Read.o )
[41 of 43] Compiling Data.Text.Lazy.Builder.RealFloat ( Data/Text/Lazy/Builder/RealFloat.hs, dist/build/Data/Text/Lazy/Builder/RealFloat.o )
ghc: panic! (the 'impossible' happened)
(GHC version 7.8.4 for i386-unknown-linux):
RegAlloc.Liveness.computeLivenss
SCCs aren't in reverse dependent order
bad blockId c8xHd
[NONREC
c8xHG: jmp *-4(%ebx),
NONREC
c8xHF:
movl $12,828(%ebx)
jmp *stg_gc_unpt_r1@got(%vI_n8Wmo),
NONREC
c8xHE:
movl %vI_n8Wmo,%vI_n8WmH
addl $sat_s8qTs{v}_info@gotoff,%vI_n8WmH
movl %vI_n8WmH,-8(%edi)
movl 4(%ebp),%vI_n8WmI
movl %vI_n8WmI,-4(%edi)
movl 16(%ebp),%vI_n8WmJ
movl %vI_n8WmJ,(%edi)
leal -7(%edi),%esi
addl $20,%ebp
jmp *(%ebp),
NONREC
c8xHz:
movl $48,828(%ebx)
movl %vI_n8Wmo,%vI_n8WmF
addl $block{v c8xEh}_info@gotoff,%vI_n8WmF
movl %vI_n8WmF,(%ebp)
movl %vI_s8qTz,%esi
movl %vI_s8qTx,4(%ebp)
jmp *stg_gc_unbx_r1@got(%vI_n8Wmo),
NONREC
c8xHq:
movl %vI_c8xEw,%esi
incl 8(%ebp)
addl $8,%ebp
jmp *stg_ap_n_fast@got(%vI_n8Wmo),
NONREC
c8xHp:
movl %vI_c8xEw,%esi
addl $8,%ebp
jmp *stg_ap_n_fast@got(%vI_n8Wmo),
NONREC
c8xHi: jmp *(%esi),
NONREC
c8xGZ:
call 1f
1: popl %vI_n8Wmo
addl $_GLOBAL_OFFSET_TABLE_+(.-1b), %vI_n8Wmo
movl 4(%ebp),%vI_c8xEw
movl %esi,%vI_n8Wmw
andl $3,%vI_n8Wmw
cmpl $2,%vI_n8Wmw
jae _c8xHp
jmp _c8xHq,
NONREC
c8xHy:
movl %vI_n8Wmo,%vI_n8Wmy
addl $lvl65{v s8qTB}_info@gotoff,%vI_n8Wmy
movl %vI_n8Wmy,-44(%edi)
movl %vI_s8qTz,-36(%edi)
movl %vI_n8Wmo,%vI_n8WmA
addl $a28{v s8qTD}_info@gotoff,%vI_n8WmA
movl %vI_n8WmA,-32(%edi)
movl %vI_s8qTd,-28(%edi)
movl %vI_s8qTh,-24(%edi)
movl %vI_s8qTk,-20(%edi)
movl %vI_s8qTx,-16(%edi)
leal -44(%edi),%vI_c8xEn
movl %vI_c8xEn,-12(%edi)
movl %vI_s8qRK,-8(%edi)
movl %vI_s8qTj,-4(%edi)
movl %vI_s8qTz,(%edi)
movl %vI_n8Wmo,%vI_n8WmC
addl $block{v c8xGZ}_info@gotoff,%vI_n8WmC
movl %vI_n8WmC,16(%ebp)
movl %vI_c8xEn,%esi
leal -30(%edi),%vI_n8WmD
movl %vI_n8WmD,20(%ebp)
addl $16,%ebp
testl $3,%esi
jne _c8xGZ
jmp _c8xHi,
NONREC
c8xGX:
addl $12,%edi
cmpl 804(%ebx),%edi
ja _c8xHF
jmp _c8xHE,
NONREC
c8xEi:
addl $48,%edi
cmpl 804(%ebx),%edi
ja _c8xHz
jmp _c8xHy,
NONREC
c8xHe:
movl %esi,%vI_s8qTx
movl $65533,%vI_s8qTz
jmp _c8xEi,
NONREC
c8xEh:
call 1f
1: popl %vI_n8Wmo
addl $_GLOBAL_OFFSET_TABLE_+(.-1b), %vI_n8Wmo
movl 20(%ebp),%vI_s8qRK
movl 12(%ebp),%vI_s8qTd
movl 16(%ebp),%vI_s8qTh
movl 24(%ebp),%vI_s8qTj
movl 8(%ebp),%vI_s8qTk
movl 4(%ebp),%vI_s8qTx
movl %esi,%vI_s8qTz
jmp _c8xEi,
NONREC
c8xEb: jmp *(%esi),
NONREC
c8xEa:
call 1f
1: popl %vI_n8Wmo
addl $_GLOBAL_OFFSET_TABLE_+(.-1b), %vI_n8Wmo
movl 20(%ebp),%vI_s8qRK
movl 12(%ebp),%vI_s8qTd
movl 16(%ebp),%vI_s8qTh
movl 24(%ebp),%vI_s8qTj
movl 8(%ebp),%vI_s8qTk
movl 4(%ebp),%vI_s8qTw
movl %vI_s8qTw,%vI_n8Wms
andl $2095104,%vI_n8Wms
cmpl $55296,%vI_n8Wms
jne _c8xHd
jmp _c8xHe,
NONREC
c8xE6: jmp *(%esi),
NONREC
c8xE5:
call 1f
1: popl %vI_n8Wmo
addl $_GLOBAL_OFFSET_TABLE_+(.-1b), %vI_n8Wmo
movl %vI_n8Wmo,%vI_n8Wmq
addl $block{v c8xEa}_info@gotoff,%vI_n8Wmq
movl %vI_n8Wmq,(%ebp)
movl 3(%esi),%vI_s8qTw
movl 4(%ebp),%esi
movl %vI_s8qTw,4(%ebp)
testl $3,%esi
jne _c8xEa
jmp _c8xEb,
NONREC
c8xGW:
movl %vI_n8Wmo,%vI_n8Wmu
addl $block{v c8xE5}_info@gotoff,%vI_n8Wmu
movl %vI_n8Wmu,-8(%ebp)
movl %esi,%vI_s8qTk
movl 6(%esi),%vI_s8qTu
movl 2(%esi),%esi
movl %vI_s8qTu,-4(%ebp)
movl %vI_s8qTk,(%ebp)
addl $-8,%ebp
testl $3,%esi
jne _c8xE5
jmp _c8xE6,
NONREC
c8xDC: jmp *(%esi),
NONREC
c8xDB:
call 1f
1: popl %vI_n8Wmo
addl $_GLOBAL_OFFSET_TABLE_+(.-1b), %vI_n8Wmo
movl %esi,%vI_n8Wmn
andl $3,%vI_n8Wmn
cmpl $2,%vI_n8Wmn
jae _c8xGW
jmp _c8xGX,
NONREC
c8xHH:
movl %vI_n8Wmo,%vI_n8WmL
addl $block{v c8xDB}_info@gotoff,%vI_n8WmL
movl %vI_n8WmL,-12(%ebp)
movl %esi,%vI_s8qTh
movl 2(%esi),%vI_s8qTd
movl 6(%esi),%vI_s8qRK
movl (%ebp),%esi
movl %vI_s8qTd,-8(%ebp)
movl %vI_s8qTh,-4(%ebp)
movl %vI_s8qRK,(%ebp)
addl $-12,%ebp
testl $3,%esi
jne _c8xDB
jmp _c8xDC,
NONREC
c8xGY:
call 1f
1: popl %vI_n8Wmo
addl $_GLOBAL_OFFSET_TABLE_+(.-1b), %vI_n8Wmo
leal -20(%ebp),%vI_n8Wml
cmpl 796(%ebx),%vI_n8Wml
jb _c8xHG
jmp _c8xHH]
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.8.4 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Panic: RegAlloc.Liveness.computeLivenss; SCCs aren't in reverse dependent order; bad blockId c8xHd","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.8.4","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I’ve found another instance of the elusive `RegAlloc.Liveness.computeLivenss` bug, by attempting to bootstrap ''cabal-install'' 1.20.0.6 with GHC 7.8.4 on 32-bit CentOS 6, released on 27/05/2013 (available on [https://aws.amazon.com/marketplace/pp/B00A6KZBC6/ Amazon EC2]).\r\n\r\nUnfortunately, I’m unable to reproduce the bug on a subsequent attempt. Cosmic rays?\r\n\r\n{{{\r\nConfiguring text-1.1.0.1...\r\nBuilding text-1.1.0.1...\r\nPreprocessing library text-1.1.0.1...\r\n[ 1 of 43] Compiling Data.Text.Internal.Read ( Data/Text/Internal/Read.hs, dist/build/Data/Text/Internal/Read.o )\r\n[ 2 of 43] Compiling Data.Text.Internal.Encoding.Utf32 ( Data/Text/Internal/Encoding/Utf32.hs, dist/build/Data/Text/Internal/Encoding/Utf32.o )\r\n[ 3 of 43] Compiling Data.Text.Internal.Fusion.Size ( Data/Text/Internal/Fusion/Size.hs, dist/build/Data/Text/Internal/Fusion/Size.o )\r\n[ 4 of 43] Compiling Data.Text.Internal.Builder.RealFloat.Functions ( Data/Text/Internal/Builder/RealFloat/Functions.hs, dist/build/Data/Text/Internal/Builder/RealFloat/Functions.o )\r\n[ 5 of 43] Compiling Data.Text.Internal.Builder.Int.Digits ( Data/Text/Internal/Builder/Int/Digits.hs, dist/build/Data/Text/Internal/Builder/Int/Digits.o )\r\n[ 6 of 43] Compiling Data.Text.Internal.Fusion.Types ( Data/Text/Internal/Fusion/Types.hs, dist/build/Data/Text/Internal/Fusion/Types.o )\r\n[ 7 of 43] Compiling Data.Text.Internal.Fusion.CaseMapping ( Data/Text/Internal/Fusion/CaseMapping.hs, dist/build/Data/Text/Internal/Fusion/CaseMapping.o )\r\n[ 8 of 43] Compiling Data.Text.Encoding.Error ( Data/Text/Encoding/Error.hs, dist/build/Data/Text/Encoding/Error.o )\r\n[ 9 of 43] Compiling Data.Text.Internal.Unsafe.Shift ( Data/Text/Internal/Unsafe/Shift.hs, dist/build/Data/Text/Internal/Unsafe/Shift.o )\r\n[10 of 43] Compiling Data.Text.Internal.Encoding.Utf16 ( Data/Text/Internal/Encoding/Utf16.hs, dist/build/Data/Text/Internal/Encoding/Utf16.o )\r\n[11 of 43] Compiling Data.Text.Internal.Functions ( Data/Text/Internal/Functions.hs, dist/build/Data/Text/Internal/Functions.o )\r\n[12 of 43] Compiling Data.Text.Internal.Unsafe ( Data/Text/Internal/Unsafe.hs, dist/build/Data/Text/Internal/Unsafe.o )\r\n[13 of 43] Compiling Data.Text.Internal.Fusion.Common ( Data/Text/Internal/Fusion/Common.hs, dist/build/Data/Text/Internal/Fusion/Common.o )\r\n[14 of 43] Compiling Data.Text.Array ( Data/Text/Array.hs, dist/build/Data/Text/Array.o )\r\n[15 of 43] Compiling Data.Text.Internal.Unsafe.Char ( Data/Text/Internal/Unsafe/Char.hs, dist/build/Data/Text/Internal/Unsafe/Char.o )\r\n[16 of 43] Compiling Data.Text.Internal ( Data/Text/Internal.hs, dist/build/Data/Text/Internal.o )\r\n[17 of 43] Compiling Data.Text.Unsafe ( Data/Text/Unsafe.hs, dist/build/Data/Text/Unsafe.o )\r\n[18 of 43] Compiling Data.Text.Internal.Private ( Data/Text/Internal/Private.hs, dist/build/Data/Text/Internal/Private.o )\r\n[19 of 43] Compiling Data.Text.Internal.Fusion ( Data/Text/Internal/Fusion.hs, dist/build/Data/Text/Internal/Fusion.o )\r\n[20 of 43] Compiling Data.Text.Internal.Encoding.Fusion.Common ( Data/Text/Internal/Encoding/Fusion/Common.hs, dist/build/Data/Text/Internal/Encoding/Fusion/Common.o )\r\n[21 of 43] Compiling Data.Text.Internal.Encoding.Utf8 ( Data/Text/Internal/Encoding/Utf8.hs, dist/build/Data/Text/Internal/Encoding/Utf8.o )\r\n[22 of 43] Compiling Data.Text.Internal.Encoding.Fusion ( Data/Text/Internal/Encoding/Fusion.hs, dist/build/Data/Text/Internal/Encoding/Fusion.o )\r\n[23 of 43] Compiling Data.Text.Internal.Lazy.Encoding.Fusion ( Data/Text/Internal/Lazy/Encoding/Fusion.hs, dist/build/Data/Text/Internal/Lazy/Encoding/Fusion.o )\r\n[24 of 43] Compiling Data.Text.Internal.Search ( Data/Text/Internal/Search.hs, dist/build/Data/Text/Internal/Search.o )\r\n[25 of 43] Compiling Data.Text ( Data/Text.hs, dist/build/Data/Text.o )\r\n[26 of 43] Compiling Data.Text.Encoding ( Data/Text/Encoding.hs, dist/build/Data/Text/Encoding.o )\r\n[27 of 43] Compiling Data.Text.Foreign ( Data/Text/Foreign.hs, dist/build/Data/Text/Foreign.o )\r\n[28 of 43] Compiling Data.Text.Internal.IO ( Data/Text/Internal/IO.hs, dist/build/Data/Text/Internal/IO.o )\r\n[29 of 43] Compiling Data.Text.IO ( Data/Text/IO.hs, dist/build/Data/Text/IO.o )\r\n[30 of 43] Compiling Data.Text.Internal.Lazy ( Data/Text/Internal/Lazy.hs, dist/build/Data/Text/Internal/Lazy.o )\r\n[31 of 43] Compiling Data.Text.Internal.Lazy.Fusion ( Data/Text/Internal/Lazy/Fusion.hs, dist/build/Data/Text/Internal/Lazy/Fusion.o )\r\n[32 of 43] Compiling Data.Text.Internal.Lazy.Search ( Data/Text/Internal/Lazy/Search.hs, dist/build/Data/Text/Internal/Lazy/Search.o )\r\n[33 of 43] Compiling Data.Text.Lazy.Internal ( Data/Text/Lazy/Internal.hs, dist/build/Data/Text/Lazy/Internal.o )\r\n[34 of 43] Compiling Data.Text.Lazy ( Data/Text/Lazy.hs, dist/build/Data/Text/Lazy.o )\r\n[35 of 43] Compiling Data.Text.Internal.Builder ( Data/Text/Internal/Builder.hs, dist/build/Data/Text/Internal/Builder.o )\r\n[36 of 43] Compiling Data.Text.Lazy.Builder ( Data/Text/Lazy/Builder.hs, dist/build/Data/Text/Lazy/Builder.o )\r\n[37 of 43] Compiling Data.Text.Internal.Builder.Functions ( Data/Text/Internal/Builder/Functions.hs, dist/build/Data/Text/Internal/Builder/Functions.o )\r\n[38 of 43] Compiling Data.Text.Lazy.Builder.Int ( Data/Text/Lazy/Builder/Int.hs, dist/build/Data/Text/Lazy/Builder/Int.o )\r\n[39 of 43] Compiling Data.Text.Lazy.IO ( Data/Text/Lazy/IO.hs, dist/build/Data/Text/Lazy/IO.o )\r\n[40 of 43] Compiling Data.Text.Lazy.Read ( Data/Text/Lazy/Read.hs, dist/build/Data/Text/Lazy/Read.o )\r\n[41 of 43] Compiling Data.Text.Lazy.Builder.RealFloat ( Data/Text/Lazy/Builder/RealFloat.hs, dist/build/Data/Text/Lazy/Builder/RealFloat.o )\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 7.8.4 for i386-unknown-linux):\r\n\tRegAlloc.Liveness.computeLivenss\r\n SCCs aren't in reverse dependent order\r\n bad blockId c8xHd\r\n [NONREC\r\n c8xHG: \tjmp *-4(%ebx),\r\n NONREC\r\n c8xHF:\r\n \tmovl $12,828(%ebx)\r\n \tjmp *stg_gc_unpt_r1@got(%vI_n8Wmo),\r\n NONREC\r\n c8xHE:\r\n \tmovl %vI_n8Wmo,%vI_n8WmH\r\n \taddl $sat_s8qTs{v}_info@gotoff,%vI_n8WmH\r\n \tmovl %vI_n8WmH,-8(%edi)\r\n \tmovl 4(%ebp),%vI_n8WmI\r\n \tmovl %vI_n8WmI,-4(%edi)\r\n \tmovl 16(%ebp),%vI_n8WmJ\r\n \tmovl %vI_n8WmJ,(%edi)\r\n \tleal -7(%edi),%esi\r\n \taddl $20,%ebp\r\n \tjmp *(%ebp),\r\n NONREC\r\n c8xHz:\r\n \tmovl $48,828(%ebx)\r\n \tmovl %vI_n8Wmo,%vI_n8WmF\r\n \taddl $block{v c8xEh}_info@gotoff,%vI_n8WmF\r\n \tmovl %vI_n8WmF,(%ebp)\r\n \tmovl %vI_s8qTz,%esi\r\n \tmovl %vI_s8qTx,4(%ebp)\r\n \tjmp *stg_gc_unbx_r1@got(%vI_n8Wmo),\r\n NONREC\r\n c8xHq:\r\n \tmovl %vI_c8xEw,%esi\r\n \tincl 8(%ebp)\r\n \taddl $8,%ebp\r\n \tjmp *stg_ap_n_fast@got(%vI_n8Wmo),\r\n NONREC\r\n c8xHp:\r\n \tmovl %vI_c8xEw,%esi\r\n \taddl $8,%ebp\r\n \tjmp *stg_ap_n_fast@got(%vI_n8Wmo),\r\n NONREC\r\n c8xHi: \tjmp *(%esi),\r\n NONREC\r\n c8xGZ:\r\n \tcall 1f\r\n 1:\tpopl\t%vI_n8Wmo\r\n \taddl\t$_GLOBAL_OFFSET_TABLE_+(.-1b), %vI_n8Wmo\r\n \tmovl 4(%ebp),%vI_c8xEw\r\n \tmovl %esi,%vI_n8Wmw\r\n \tandl $3,%vI_n8Wmw\r\n \tcmpl $2,%vI_n8Wmw\r\n \tjae _c8xHp\r\n \tjmp _c8xHq,\r\n NONREC\r\n c8xHy:\r\n \tmovl %vI_n8Wmo,%vI_n8Wmy\r\n \taddl $lvl65{v s8qTB}_info@gotoff,%vI_n8Wmy\r\n \tmovl %vI_n8Wmy,-44(%edi)\r\n \tmovl %vI_s8qTz,-36(%edi)\r\n \tmovl %vI_n8Wmo,%vI_n8WmA\r\n \taddl $a28{v s8qTD}_info@gotoff,%vI_n8WmA\r\n \tmovl %vI_n8WmA,-32(%edi)\r\n \tmovl %vI_s8qTd,-28(%edi)\r\n \tmovl %vI_s8qTh,-24(%edi)\r\n \tmovl %vI_s8qTk,-20(%edi)\r\n \tmovl %vI_s8qTx,-16(%edi)\r\n \tleal -44(%edi),%vI_c8xEn\r\n \tmovl %vI_c8xEn,-12(%edi)\r\n \tmovl %vI_s8qRK,-8(%edi)\r\n \tmovl %vI_s8qTj,-4(%edi)\r\n \tmovl %vI_s8qTz,(%edi)\r\n \tmovl %vI_n8Wmo,%vI_n8WmC\r\n \taddl $block{v c8xGZ}_info@gotoff,%vI_n8WmC\r\n \tmovl %vI_n8WmC,16(%ebp)\r\n \tmovl %vI_c8xEn,%esi\r\n \tleal -30(%edi),%vI_n8WmD\r\n \tmovl %vI_n8WmD,20(%ebp)\r\n \taddl $16,%ebp\r\n \ttestl $3,%esi\r\n \tjne _c8xGZ\r\n \tjmp _c8xHi,\r\n NONREC\r\n c8xGX:\r\n \taddl $12,%edi\r\n \tcmpl 804(%ebx),%edi\r\n \tja _c8xHF\r\n \tjmp _c8xHE,\r\n NONREC\r\n c8xEi:\r\n \taddl $48,%edi\r\n \tcmpl 804(%ebx),%edi\r\n \tja _c8xHz\r\n \tjmp _c8xHy,\r\n NONREC\r\n c8xHe:\r\n \tmovl %esi,%vI_s8qTx\r\n \tmovl $65533,%vI_s8qTz\r\n \tjmp _c8xEi,\r\n NONREC\r\n c8xEh:\r\n \tcall 1f\r\n 1:\tpopl\t%vI_n8Wmo\r\n \taddl\t$_GLOBAL_OFFSET_TABLE_+(.-1b), %vI_n8Wmo\r\n \tmovl 20(%ebp),%vI_s8qRK\r\n \tmovl 12(%ebp),%vI_s8qTd\r\n \tmovl 16(%ebp),%vI_s8qTh\r\n \tmovl 24(%ebp),%vI_s8qTj\r\n \tmovl 8(%ebp),%vI_s8qTk\r\n \tmovl 4(%ebp),%vI_s8qTx\r\n \tmovl %esi,%vI_s8qTz\r\n \tjmp _c8xEi,\r\n NONREC\r\n c8xEb: \tjmp *(%esi),\r\n NONREC\r\n c8xEa:\r\n \tcall 1f\r\n 1:\tpopl\t%vI_n8Wmo\r\n \taddl\t$_GLOBAL_OFFSET_TABLE_+(.-1b), %vI_n8Wmo\r\n \tmovl 20(%ebp),%vI_s8qRK\r\n \tmovl 12(%ebp),%vI_s8qTd\r\n \tmovl 16(%ebp),%vI_s8qTh\r\n \tmovl 24(%ebp),%vI_s8qTj\r\n \tmovl 8(%ebp),%vI_s8qTk\r\n \tmovl 4(%ebp),%vI_s8qTw\r\n \tmovl %vI_s8qTw,%vI_n8Wms\r\n \tandl $2095104,%vI_n8Wms\r\n \tcmpl $55296,%vI_n8Wms\r\n \tjne _c8xHd\r\n \tjmp _c8xHe,\r\n NONREC\r\n c8xE6: \tjmp *(%esi),\r\n NONREC\r\n c8xE5:\r\n \tcall 1f\r\n 1:\tpopl\t%vI_n8Wmo\r\n \taddl\t$_GLOBAL_OFFSET_TABLE_+(.-1b), %vI_n8Wmo\r\n \tmovl %vI_n8Wmo,%vI_n8Wmq\r\n \taddl $block{v c8xEa}_info@gotoff,%vI_n8Wmq\r\n \tmovl %vI_n8Wmq,(%ebp)\r\n \tmovl 3(%esi),%vI_s8qTw\r\n \tmovl 4(%ebp),%esi\r\n \tmovl %vI_s8qTw,4(%ebp)\r\n \ttestl $3,%esi\r\n \tjne _c8xEa\r\n \tjmp _c8xEb,\r\n NONREC\r\n c8xGW:\r\n \tmovl %vI_n8Wmo,%vI_n8Wmu\r\n \taddl $block{v c8xE5}_info@gotoff,%vI_n8Wmu\r\n \tmovl %vI_n8Wmu,-8(%ebp)\r\n \tmovl %esi,%vI_s8qTk\r\n \tmovl 6(%esi),%vI_s8qTu\r\n \tmovl 2(%esi),%esi\r\n \tmovl %vI_s8qTu,-4(%ebp)\r\n \tmovl %vI_s8qTk,(%ebp)\r\n \taddl $-8,%ebp\r\n \ttestl $3,%esi\r\n \tjne _c8xE5\r\n \tjmp _c8xE6,\r\n NONREC\r\n c8xDC: \tjmp *(%esi),\r\n NONREC\r\n c8xDB:\r\n \tcall 1f\r\n 1:\tpopl\t%vI_n8Wmo\r\n \taddl\t$_GLOBAL_OFFSET_TABLE_+(.-1b), %vI_n8Wmo\r\n \tmovl %esi,%vI_n8Wmn\r\n \tandl $3,%vI_n8Wmn\r\n \tcmpl $2,%vI_n8Wmn\r\n \tjae _c8xGW\r\n \tjmp _c8xGX,\r\n NONREC\r\n c8xHH:\r\n \tmovl %vI_n8Wmo,%vI_n8WmL\r\n \taddl $block{v c8xDB}_info@gotoff,%vI_n8WmL\r\n \tmovl %vI_n8WmL,-12(%ebp)\r\n \tmovl %esi,%vI_s8qTh\r\n \tmovl 2(%esi),%vI_s8qTd\r\n \tmovl 6(%esi),%vI_s8qRK\r\n \tmovl (%ebp),%esi\r\n \tmovl %vI_s8qTd,-8(%ebp)\r\n \tmovl %vI_s8qTh,-4(%ebp)\r\n \tmovl %vI_s8qRK,(%ebp)\r\n \taddl $-12,%ebp\r\n \ttestl $3,%esi\r\n \tjne _c8xDB\r\n \tjmp _c8xDC,\r\n NONREC\r\n c8xGY:\r\n \tcall 1f\r\n 1:\tpopl\t%vI_n8Wmo\r\n \taddl\t$_GLOBAL_OFFSET_TABLE_+(.-1b), %vI_n8Wmo\r\n \tleal -20(%ebp),%vI_n8Wml\r\n \tcmpl 796(%ebx),%vI_n8Wml\r\n \tjb _c8xHG\r\n \tjmp _c8xHH]\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/7898SpecConstr explodes when compiling module BSP of frag-1.1.22022-04-25T19:06:30ZTinctoriusSpecConstr explodes when compiling module BSP of frag-1.1.2GHC will get stuck when trying to compile [Frag](http://www.haskell.org/haskellwiki/Frag). Steps to reproduce:
1. Get Frag 1.1.2 from the Darcs repository (`darcs get http://code.haskell.org/frag`), or from snowmantw's !GitHub fork (`gi...GHC will get stuck when trying to compile [Frag](http://www.haskell.org/haskellwiki/Frag). Steps to reproduce:
1. Get Frag 1.1.2 from the Darcs repository (`darcs get http://code.haskell.org/frag`), or from snowmantw's !GitHub fork (`git clone https://github.com/snowmantw/Frag.git`).
1. Fix the code so it'll actually compile:
`
diff --git a/src/Textures.hs b/src/Textures.hs
index 7383fd8..b5516a5 100644
--- a/src/Textures.hs
+++ b/src/Textures.hs
@@ -10,6 +10,7 @@ import Graphics.UI.GLUT
import TGA (readTga)
import Data.Word (Word8)
import Foreign.Marshal.Alloc (free)
+import Control.Exception (catch, SomeException)
-- read a list of images and returns a list of textures
@@ -32,7 +33,8 @@ getAndCreateTexture fileName = do
-- read the image data
readImageC :: String -> IO (Maybe (Size, PixelData Word8))
-readImageC path = catch (readTga path) (\_ -> do print ("missing texture: "++path)
+readImageC path = catch (readTga path) (\e -> do print (e :: SomeException)
+ print ("missing texture: "++path)
return Nothing)
`
1. `cabal configure`
1. `cabal build`
GHC will get stuck on the module `BSP` and consume memory until it crashes. According to [this ticket on the GitHub fork mentioned earlier](https://github.com/snowmantw/Frag/issues/1), this problem only occurs with `-O2`.
When I split the reading part of the module (`readBSP` and all functions it depends on), it crashed on that part. Will investigate further.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.6.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Compiler diverges when compiling module BSP of frag-1.1.2","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.6.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"GHC will get stuck when trying to compile [http://www.haskell.org/haskellwiki/Frag Frag]. Steps to reproduce:\r\n\r\n 1. Get Frag 1.1.2 from the Darcs repository (`darcs get http://code.haskell.org/frag`), or from snowmantw's !GitHub fork (`git clone https://github.com/snowmantw/Frag.git`).\r\n 1. Fix the code so it'll actually compile:\r\n {{{\r\ndiff --git a/src/Textures.hs b/src/Textures.hs\r\nindex 7383fd8..b5516a5 100644\r\n--- a/src/Textures.hs\r\n+++ b/src/Textures.hs\r\n@@ -10,6 +10,7 @@ import Graphics.UI.GLUT\r\n import TGA (readTga)\r\n import Data.Word (Word8)\r\n import Foreign.Marshal.Alloc (free)\r\n+import Control.Exception (catch, SomeException)\r\n \r\n \r\n -- read a list of images and returns a list of textures\r\n@@ -32,7 +33,8 @@ getAndCreateTexture fileName = do\r\n \r\n -- read the image data\r\n readImageC :: String -> IO (Maybe (Size, PixelData Word8))\r\n-readImageC path = catch (readTga path) (\\_ -> do print (\"missing texture: \"++path)\r\n+readImageC path = catch (readTga path) (\\e -> do print (e :: SomeException)\r\n+ print (\"missing texture: \"++path)\r\n return Nothing)\r\n \r\n }}}\r\n 1. `cabal configure`\r\n 1. `cabal build`\r\n\r\nGHC will get stuck on the module `BSP` and consume memory until it crashes. According to [https://github.com/snowmantw/Frag/issues/1 this ticket on the GitHub fork mentioned earlier], this problem only occurs with `-O2`.\r\n\r\nWhen I split the reading part of the module (`readBSP` and all functions it depends on), it crashed on that part. Will investigate further.","type_of_failure":"OtherFailure","blocking":[]} -->7.8.4https://gitlab.haskell.org/ghc/ghc/-/issues/21302Panic on particular combination of UndecidableInstances, StandaloneDeriving, ...2022-04-07T17:26:42ZmaynardPanic on particular combination of UndecidableInstances, StandaloneDeriving, TypeFamilies, and ConstraintKinds## Summary
This program:
```haskell
{-# LANGUAGE UndecidableInstances, StandaloneDeriving, TypeFamilies, ConstraintKinds #-}
module Bug where
data BoxAssocDouble = BoxAssocDouble (BoxAssoc Int)
deriving (Eq)
type family Assoc a
d...## Summary
This program:
```haskell
{-# LANGUAGE UndecidableInstances, StandaloneDeriving, TypeFamilies, ConstraintKinds #-}
module Bug where
data BoxAssocDouble = BoxAssocDouble (BoxAssoc Int)
deriving (Eq)
type family Assoc a
data BoxAssoc a = BoxAssoc (Assoc a)
deriving instance c Eq a => Eq (BoxAssoc a)
```
Panics with this error:
```
[1 of 1] Compiling Bug ( bug.hs, bug.o )
ghc: panic! (the 'impossible' happened)
(GHC version 9.2.1:
solveDerivEqns: probable loop
DerivSpec
ds_loc = bug.hs:6:13-14
ds_name = $fEqBoxAssocDouble
ds_tvs = []
ds_cls = Eq
ds_tys = [BoxAssocDouble]
ds_theta = [ThetaOrigin
to_anyclass_skols = []
to_anyclass_metas = []
to_anyclass_givens = []
to_wanted_origins = [],
ThetaOrigin
to_anyclass_skols = []
to_anyclass_metas = []
to_anyclass_givens = []
to_wanted_origins = [],
ThetaOrigin
to_anyclass_skols = []
to_anyclass_metas = []
to_anyclass_givens = []
to_wanted_origins = [],
ThetaOrigin
to_anyclass_skols = []
to_anyclass_metas = []
to_anyclass_givens = []
to_wanted_origins = [Eq (BoxAssoc Int)]]
ds_standalone_wildcard = Nothing
ds_mechanism = DerivSpecStock
dsm_stock_dit DITTyConHead
dit_cls_tys []
dit_tc BoxAssocDouble
dit_tc_args []
dit_rep_tc BoxAssocDouble
dit_rep_tc_args []
[[c_aIT[tau:1] Eq Int]]
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/Tc/Deriv/Infer.hs:665:9 in ghc:GHC.Tc.Deriv.Infer
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
## Steps to reproduce
Run the above MWE with a modern-enough version of GHC. (Tested with 8.6.5 and 9.2.1)
## Expected behavior
Honestly, I don't know. I discovered this bug by writing
```haskell
deriving instance stock Eq a => Eq (BoxAssoc a)
```
intending to combine `StandaloneDeriving` with `DerivingStrategies`. It seems, however, that GHC parses `stock Eq a` as a constraint, and then promptly crashes.
## Environment
* GHC version used: 9.2.1 (also 8.6.5)
* Operating System: Pop!_OS 20.10
* System Architecture: 64-bitRyan ScottRyan Scotthttps://gitlab.haskell.org/ghc/ghc/-/issues/20639panic in refineFromInScope with 9.2.12022-03-31T02:23:24Zquarkpanic in refineFromInScope with 9.2.1## Summary
The [Bluespec Compiler (BSC)](https://github.com/B-Lang-org/bsc) has been compiling with GHC 9.0.1, 8.10.7, etc, but when attempting to compile with 9.2.1, it encounters a panic in `refineFromInScope`. I have reduced it to a...## Summary
The [Bluespec Compiler (BSC)](https://github.com/B-Lang-org/bsc) has been compiling with GHC 9.0.1, 8.10.7, etc, but when attempting to compile with 9.2.1, it encounters a panic in `refineFromInScope`. I have reduced it to a small example, which compiles fine when GHC is called with no flags, but encounters the panic when called with `-O2`:
```
$ ghc -O2 CtxRed.hs
[1 of 1] Compiling CtxRed ( CtxRed.hs, CtxRed.o )
ghc: panic! (the 'impossible' happened)
(GHC version 9.2.1:
refineFromInScope
InScope {wild_00 wild_X1 s1_X4 d_aF3 incoh_aF4 cpreds_aF5
$cctxRed_aJC $krep_aKv $krep_aKw $krep_aKx $krep_aKy $krep_aKz
$krep_aKA $krep_aKB $krep_aKC $krep_aKD $krep_aKE $krep_aKF
$krep_aKG $krep_aKH $krep_aKI $krep_aKJ $krep_aKK $krep_aKL
$krep_aKM $krep_aKN $krep_aKO $krep_aKP $krep_aKQ $krep_aKR
wild_aPf x_aPi s1_aPv wild_aPx a1_aPy s'_aPz ctxRedCQType'
$tc'CTypeclass $tcCTypeclass $tc'CPred $tcCPred $tc'CQType
$tcCQType $tc'Cclass $tcCDefn $tcCtxRed $tc'C:CtxRed $fCtxRedCDefn
$trModule $trModule_sN7 $trModule_sN8 $trModule_sN9 $trModule_sNa
$krep_sNb $krep_sNc $krep_sNd $krep_sNe $krep_sNf $krep_sNg
$krep_sNh $krep_sNi $krep_sNj $krep_sNk $tcCTypeclass_sNl
$tcCTypeclass_sNm $tc'CTypeclass_sNn $tc'CTypeclass_sNo
$tcCPred_sNp $tcCPred_sNq $tc'CPred_sNr $tc'CPred_sNs $krep_sNt
$tcCQType_sNu $tcCQType_sNv $tc'CQType_sNw $tc'CQType_sNx
$tcCDefn_sNy $tcCDefn_sNz $tc'Cclass_sNA $tc'Cclass_sNB
$tcCtxRed_sNC $tcCtxRed_sND $krep_sNE $tc'C:CtxRed_sNF
$tc'C:CtxRed_sNG ds_sPV m1_sPW lvl_sQ4 lvl_sQ5 m1_sQ7 lvl_sQ8}
s'_X7
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
```
I do not know if this is related to the two other issues that mention a panic in `refineFromInScope` (#20419 and #19360).
## Steps to reproduce
Place the following example in a file called `CtxRed.hs`:
```
module CtxRed(ctxRedCQType', CtxRed(..)) where
import Control.Monad.State
import Control.Monad.Except
type TI = StateT Bool (ExceptT [Integer] (State Bool))
data CDefn = Cclass (Maybe Bool) [CPred]
data CQType = CQType [CPred]
data CTypeclass = CTypeclass
data CPred = CPred CTypeclass
class CtxRed a where
ctxRed :: a -> TI a
instance CtxRed CDefn where
ctxRed d@(Cclass incoh cpreds) = do
(CQType _) <- ctxRedCQType' (CQType [])
return (Cclass incoh cpreds)
ctxRedCQType' :: CQType -> TI (CQType)
ctxRedCQType' cqt = do
let CQType cqs = cqt
case [p | p@(CPred CTypeclass) <- cqs] of
p : _ -> return ()
[] -> return ()
return (cqt)
```
And execute:
```
ghc -O2 CtxRed.hs
```
If you would like to reproduce the original error in BSC (which has 226 Haskell source files, imported foreign functions, etc), instructions for building BSC can be found at https://github.com/B-Lang-org/bsc/blob/main/INSTALL.md
## Expected behavior
If I execute GHC without the `-O2` flag, or if I use a version such as 9.0.1 or 8.10.7, there are no errors or warnings:
```
$ ghc CtxRed.hs
[1 of 1] Compiling CtxRed ( CtxRed.hs, CtxRed.o )
```
This small example has no real meaning; in the BSC project, with the original `CtxRed.hs` file, the module compiles and GHC continues compiling the rest of the modules and generates an executable, which can then be run against the BSC testsuite.
## Environment
As said above, this occurs with GHC 9.2.1.
The small example was developed on macOS 11.6. The original BSC issue can be seen both on GitHub's Ubuntu 18.04/20.04 VMs (in the BSC project's automated testing) and locally for me on macOS 11.6.9.2.2https://gitlab.haskell.org/ghc/ghc/-/issues/19360panic refineFromInScope from 3b8235334b7838013c9e955db3e7762a1c7fef432022-03-31T02:23:24ZAlan Zimmermanpanic refineFromInScope from 3b8235334b7838013c9e955db3e7762a1c7fef43## Summary
After 3b8235334b7838013c9e955db3e7762a1c7fef43 landed, my TTG `Dump.hs` for API annotations causes a panic on `refineFromInscope`.
I minimised this to a reproduction from
```haskell
{-# LANGUAGE DeriveDataTypeable #-}
{-# L...## Summary
After 3b8235334b7838013c9e955db3e7762a1c7fef43 landed, my TTG `Dump.hs` for API annotations causes a panic on `refineFromInscope`.
I minimised this to a reproduction from
```haskell
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module GHC.Hs.Dump1 where
import qualified GHC.Utils.Ppr as Pretty
import GHC.Prelude (Maybe(..), maybe,Bool (True), ($), head)
import Data.Data (Data,Typeable, gmapQ, cast)
import Data.String
import GHC.Exts (oneShot)
runSDoc :: SDoc -> (Bool -> Pretty.Doc)
runSDoc (SDoc m) = m
{-# COMPLETE SDoc #-}
pattern SDoc :: (Bool -> Pretty.Doc) -> SDoc
pattern SDoc m <- SDoc' m
where
SDoc m = SDoc' (oneShot m)
newtype SDoc = SDoc' (Bool -> Pretty.Doc)
vcat :: [SDoc] -> SDoc
vcat ds = head ds
docToSDoc :: Pretty.Doc -> SDoc
docToSDoc d = SDoc (\_ -> d)
text :: String -> SDoc
text s = docToSDoc $ Pretty.text s
data SrcSpanAnn' a = SrcSpanAnn a
deriving (Data)
data ApiAnn' ann
= ApiAnn ann
deriving (Data)
showAstData :: Data a => Bool -> a -> SDoc
showAstData ba a0 = showAstData' a0
where
showAstData' :: Data a => a -> SDoc
showAstData' =
generic `extQ` srcSpanAnnA
where generic :: Data a => a -> SDoc
generic t = vcat (gmapQ showAstData' t)
srcSpanAnnA :: SrcSpanAnn' (ApiAnn' ()) -> SDoc
srcSpanAnnA = locatedAnn''
locatedAnn'' :: forall a. (Typeable a, Data a)
=> SrcSpanAnn' a -> SDoc
locatedAnn'' ss =
case cast ss of
Just ((SrcSpanAnn ann ) :: SrcSpanAnn' a) ->
case ba of
True
-> showAstData' ann
Nothing -> text "locatedAnn:unmatched"
-- | Extend a generic query by a type-specific case
extQ :: ( Typeable a
, Typeable b
)
=> (a -> q)
-> (b -> q)
-> a
-> q
extQ f g a = maybe (f a) g (cast a)
```
which gives
```
compiler/GHC/Hs/Dump1.hs:62:19: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In a case alternative:
Patterns of type ‘Bool’ not matched: ghc-prim:GHC.Types.False
|
62 | case ba of
| ^^^^^^^^^^...
ghc: panic! (the 'impossible' happened)
(GHC version 9.1.20210130:
refineFromInScope
InScope {wild_00 eta_B0 ba_a1w2 a0_a1w3 $tApiAnn'_a1ya
$cApiAnn_a1yb $tSrcSpanAnn'_a1yc $cSrcSpanAnn_a1yd a_a32a
$dData_a32b $cgfoldl_a3aO $cdataCast1_a3bC $cgmapQl_a3cD
$cgmapQr_a3cW $cgmapQ_a3de $cgmapQi_a3dr $cgmapM_a3dG $cgmapMp_a3e0
$cgmapMo_a3ek $cgfoldl_a3eG $cdataCast1_a3fm $cgmapQl_a3fY
$cgmapQr_a3ga $cgmapQ_a3gm $cgmapQi_a3gw $cgmapM_a3gG $cgmapMp_a3gS
$cgmapMo_a3h4 $krep_a3kK $krep_a3kL $krep_a3kM $krep_a3kN
$krep_a3kO $krep_a3kP $krep_a3kQ $krep_a3kR $krep_a3kS $krep_a3kT
runSDoc vcat docToSDoc text showAstData extQ $tc'SDoc' $tcSDoc
$tc'SrcSpanAnn $tcSrcSpanAnn' $tc'ApiAnn $tcApiAnn' $fDataApiAnn'
$fDataSrcSpanAnn' $mSDoc $bSDoc $trModule $bSDoc_s3NK
docToSDoc_s3NL text_s3NP runSDoc_s3NQ $cApiAnn_s3Ol $cApiAnn_s3Om
$cApiAnn_s3On $tApiAnn'_s3Oo $tApiAnn'_s3Op $tApiAnn'_s3Oq
$cSrcSpanAnn_s3Or $cSrcSpanAnn_s3Os $cSrcSpanAnn_s3Ot
$tSrcSpanAnn'_s3Ou $tSrcSpanAnn'_s3Ov $tSrcSpanAnn'_s3Ow
$trModule_s3Ox $trModule_s3Oy $trModule_s3Oz $trModule_s3OA
$krep_s3OB $tcSDoc_s3OC $tcSDoc_s3OD $tc'SDoc'_s3OE $tc'SDoc'_s3OF
$tcSrcSpanAnn'_s3OG $tcSrcSpanAnn'_s3OH $krep_s3OI
$tc'SrcSpanAnn_s3OJ $tc'SrcSpanAnn_s3OK $cp1Data_s3Pk
$tcApiAnn'_s3R4 $tcApiAnn'_s3R5 $krep_s3R6 $tc'ApiAnn_s3R7
$tc'ApiAnn_s3R8 $cp1Data_s3R9 $cgmapT_s3RT $cgmapT_s3RU
showAstData'_s3RW $dTypeable_s3S2 $dTypeable_s3S3 $dTypeable_s3S6
$dData_s3S7 $dTypeable_s3Sd $dTypeable_s3Se $dTypeable_s3Sh
$s$fDataApiAnn'_s3Sl $s$cgmapMo_s3Ss $s$cgmapT_s3Su $s$cgmapQl_s3Sw
$s$cgmapQ_s3Sy $s$cgmapQr_s3SA $s$cgmapQi_s3SC $s$cgmapM_s3SE
$s$cgmapMp_s3SK $s$cdataCast1_s3SQ $s$cp1Data_s3SS $s$cgfoldl_s3T0
$scast_s3T6 $scast_s3T9 lvl_s3Tg lvl_s3Th lvl_s3Ti lvl_s3Tj
lvl_s3Tk lvl_s3Tl lvl_s3Tm lvl_s3Tn lvl_s3To lvl_s3Tp lvl_s3Tq
lvl_s3Tr lvl_s3Tv lvl_s3Tw lvl_s3Tx lvl_s3Ty lvl_s3Tz lvl_s3TC
lvl_s3TD lvl_s3TG lvl_s3U0 lvl_s3U1 lvl_s3Ul lvl_s3Um lvl_s3Uo
lvl_s3Uq lvl_s3Ur lvl_s3Uu lvl_s3Uv $dTypeable_s3Uz $dTypeable_s3UC
lvl_s3UE lvl_s3UG lvl_s3UH lvl_s3UJ lvl_s3UK lvl_s3UL lvl_s3UM
lvl_s3UN lvl_s3UT $dTypeable_s3UV lvl_s3UX lvl_s3UY lvl_s3V1
lvl_s3V3 lvl_s3Vn lvl_s3Vo lvl_s3Vp lvl_s3Vs lvl_s3Vt lvl_s3Vu
lvl_s3Vx lvl_s3Vz lvl_s3VC lvl_s3VE $dTypeable_s3VF
$sshowAstData'_s3VJ showAstData'_s3VM showAstData_s3VN}
$sshowAstData'_s3Si
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:685:30 in ghc:GHC.Core.Opt.Simplify.Env
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
## Steps to reproduce
Build GHC from commit 3b8235334b7838013c9e955db3e7762a1c7fef43
Invoke the stage0 compiler on the Dump1.hs file shown above. My command line (from invoking hadrian with -V, will not be portable) is
```
_build/stage0/bin/ghc -Wall -fdiagnostics-color=never -hisuf p_hi -osuf p_o -hcsuf p_hc -static -prof -eventlog -hide-all-packages -no-user-package-db '-package-env -' '-package-db _build/stage1/lib/package.conf.d' '-this-unit-id ghc-9.1' '-package-id array-0.5.4.0' '-package-id base-4.16.0.0' '-package-id binary-0.8.7.0' '-package-id bytestring-0.10.12.0' '-package-id containers-0.6.4.1' '-package-id deepseq-1.4.4.0' '-package-id directory-1.3.6.1' '-package-id exceptions-0.10.4' '-package-id filepath-1.4.2.1' '-package-id ghc-boot-9.1' '-package-id ghc-heap-9.1' '-package-id ghci-9.1' '-package-id hpc-0.6.1.0' '-package-id parsec-3.1.14.0' '-package-id process-1.6.10.0' '-package-id template-haskell-2.17.0.0' '-package-id terminfo-0.4.1.4' '-package-id time-1.11.1.1' '-package-id transformers-0.5.6.2' '-package-id unix-2.7.2.2' -i -i/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/compiler/build -i/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/compiler/build/autogen -i/home/alanz/mysrc/git.haskell.org/worktree/exactprint/compiler -Iincludes -I_build/stage1/lib -I_build/stage1/compiler/build -I_build/stage1/compiler/build/. -I_build/stage1/compiler/build/../rts/dist/build -Icompiler/. -Icompiler/../rts/dist/build -I/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/x86_64-linux-ghc-9.1.20210212/process-1.6.10.0/include -I/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/x86_64-linux-ghc-9.1.20210212/unix-2.7.2.2/include -I/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/x86_64-linux-ghc-9.1.20210212/time-1.11.1/include -I/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/x86_64-linux-ghc-9.1.20210212/bytestring-0.10.12.0/include -I/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/x86_64-linux-ghc-9.1.20210212/base-4.16.0.0/include -I/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/x86_64-linux-ghc-9.1.20210212/ghc-bignum-1.0/include -I/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/x86_64-linux-ghc-9.1.20210212/rts-1.0/include -I_build/stage1/lib -optc-I_build/stage1/lib -optP-include -optP_build/stage1/compiler/build/autogen/cabal_macros.h -optP-DHAVE_INTERNAL_INTERPRETER -optP-DCAN_LOAD_DLL -outputdir _build/stage1/compiler/build -Wnoncanonical-monad-instances -optc-Wno-error=inline -optP-Wno-nonportable-include-path -c compiler/GHC/Hs/Dump1.hs -o _build/stage1/compiler/build/GHC/Hs/Dump.p_o -O2 -H32m -Wall -Wno-name-shadowing -Wnoncanonical-monad-instances -Wnoncanonical-monoid-instances -this-unit-id ghc -XHaskell2010 -XNoImplicitPrelude -XBangPatterns -XScopedTypeVariables -XMonoLocalBinds -no-global-package-db -package-db=/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/package.conf.d -ghcversion-file=/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/ghcversion.h -Wno-deprecated-flags -Wcpp-undef
```
## Expected behavior
It should compile without a panic
## Environment
* GHC version used: 3b8235334b7838013c9e955db3e7762a1c7fef43
Optional:
* Operating System: Debian testing
* System Architecture: amd64
FYI, my bisect log is
```
$ git bisect log
git bisect start
# bad: [ab5fd982a7a501136cb8b90fa841c02cc9551b5a] Bump Haddock submodule
git bisect bad ab5fd982a7a501136cb8b90fa841c02cc9551b5a
# good: [81f0665513d65c2d7e544cbe8adeff4b0d6fdfff] Separate AST from GhcPass (#18936)
git bisect good 81f0665513d65c2d7e544cbe8adeff4b0d6fdfff
# good: [ae8379abb8aa1defc86dc60bece70546d42af177] Ppr: compute length of string literals at compile time (#19266)
git bisect good ae8379abb8aa1defc86dc60bece70546d42af177
# bad: [6085cfb5e508e969ecb69d8dbeb8cfd1fb87ca3d] Remove misleading 'lazy' pattern matches from 'head' and 'tail' in Data.List.NonEmpty
git bisect bad 6085cfb5e508e969ecb69d8dbeb8cfd1fb87ca3d
# bad: [a3d995fa18079ac31623febc8f41297c9acfb6a5] Fix -dynamic-too with wired-in modules (#19264)
git bisect bad a3d995fa18079ac31623febc8f41297c9acfb6a5
# bad: [f5d62eb2d5a1058f355aaa1fd0a959694d160ec4] ghci: Take editor from VISUAL environment variable
git bisect bad f5d62eb2d5a1058f355aaa1fd0a959694d160ec4
# bad: [3b8235334b7838013c9e955db3e7762a1c7fef43] Make PatSyn immutable
git bisect bad 3b8235334b7838013c9e955db3e7762a1c7fef43
# good: [5140841ca1acaeaeef893233ae3d08ce4573b01b] Fix check-uniques script
git bisect good 5140841ca1acaeaeef893233ae3d08ce4573b01b
# first bad commit: [3b8235334b7838013c9e955db3e7762a1c7fef43] Make PatSyn immutable
```9.2.1https://gitlab.haskell.org/ghc/ghc/-/issues/5287The 'impossible' happened. solveDerivEqns: probable loop2022-03-29T09:27:05ZagocoronaThe 'impossible' happened. solveDerivEqns: probable loopThis code:
```
{-# LANGUAGE FlexibleInstances, UndecidableInstances
, MultiParamTypeClasses
#-}
class Serializable a b
class IResource a --The rest of the instance definitions does not matter for...This code:
```
{-# LANGUAGE FlexibleInstances, UndecidableInstances
, MultiParamTypeClasses
#-}
class Serializable a b
class IResource a --The rest of the instance definitions does not matter for the error
instance Serializable a b => IResource a
data DBRef a= DBRef String a
instance (IResource a) => Read (DBRef a)
data Votation a= Votation{
content :: DBRef a
} deriving (Read)
```
gives the following error at compilation time:
```
tests>runghc impossiblelloop.hs
ghc: panic! (the 'impossible' happened)
(GHC version 7.0.3 for i386-unknown-mingw32):
solveDerivEqns: probable loop
(impossiblelloop.hs:20:13-16 main:Main.$fReadVotation{v rhI} [a{tv abB} [tv]
] base:GHC.Read.Read{tc 2d} [main:Main.Votation{tc rbo}
a{tv abB} [tv]] = [base:GHC.Read.Read{tc 2d}
(main:Main.DBRef{tc rbu}
a{tv abB} [tv])])
[[main:Main.Serializable{tc rbA} a{tv abB} [tv] b{tv ajE} [tcs]]]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```7.4.1Simon Peyton JonesSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/21265winery-1.3.2 panics on HEAD (expectJust isRecDataCon:go_tc_app)2022-03-26T17:38:23ZRyan Scottwinery-1.3.2 panics on HEAD (expectJust isRecDataCon:go_tc_app)_(Originally discovered in a `head.hackage` build [here](https://gitlab.haskell.org/RyanGlScott/head.hackage/-/jobs/983508#L4976).)_
The `winery-1.3.2` library on Hackage panics when compiled with GHC HEAD at commit bb779b90bb093274ccf7..._(Originally discovered in a `head.hackage` build [here](https://gitlab.haskell.org/RyanGlScott/head.hackage/-/jobs/983508#L4976).)_
The `winery-1.3.2` library on Hackage panics when compiled with GHC HEAD at commit bb779b90bb093274ccf7a8e5b19f6661f4925bde. Here is a minimized example:
```hs
{-# LANGUAGE RankNTypes #-}
module Codec.Winery.Class (extractorProduct') where
class GSerialiseProduct f where
dummy :: f x -> ()
productExtractor :: TransFusion [] ((->) Bool) (f Int)
extractorProduct' :: GSerialiseProduct f => Maybe (f Int)
extractorProduct' = unTransFusion productExtractor go
go :: f x -> Maybe (g x)
go _ = Nothing
newtype TransFusion f g a = TransFusion { unTransFusion :: forall h. Applicative h => (forall x. f x -> h (g x)) -> h a }
```
```
$ ~/Software/ghc-9.3.20220316/bin/ghc Bug.hs -O -fforce-recomp
[1 of 1] Compiling Codec.Winery.Class ( Bug.hs, Bug.o )
<no location info>: error:
expectJust isRecDataCon:go_tc_app
CallStack (from HasCallStack):
error, called at compiler/GHC/Data/Maybe.hs:71:27 in ghc:GHC.Data.Maybe
expectJust, called at compiler/GHC/Core/Opt/WorkWrap/Utils.hs:1348:25 in ghc:GHC.Core.Opt.WorkWrap.Utils
```
This regression was introduced in commit 8ff32124c8cd37050f3dc7cbb32b8d41711ebcaf (`DmdAnal: Don't unbox recursive data types`). cc @sgraf8129.4.1Sebastian GrafSebastian Grafhttps://gitlab.haskell.org/ghc/ghc/-/issues/14040Typed holes regression in GHC 8.0.2: No skolem info: z_a1sY[sk:2]2022-03-22T09:23:50ZRyan ScottTyped holes regression in GHC 8.0.2: No skolem info: z_a1sY[sk:2](Originally spun off from #13877.)
The following program gives a somewhat decent error message in GHC 8.0.1:
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-...(Originally spun off from #13877.)
The following program gives a somewhat decent error message in GHC 8.0.1:
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
module Bug where
import Data.Kind
data family Sing (a :: k)
data WeirdList :: Type -> Type where
WeirdNil :: WeirdList a
WeirdCons :: a -> WeirdList (WeirdList a) -> WeirdList a
data instance Sing (z :: WeirdList a) where
SWeirdNil :: Sing WeirdNil
SWeirdCons :: Sing w -> Sing wws -> Sing (WeirdCons w wws)
elimWeirdList :: forall (a :: Type) (wl :: WeirdList a)
(p :: forall (x :: Type). x -> WeirdList x -> Type).
Sing wl
-> (forall (y :: Type). p _ WeirdNil)
-> (forall (z :: Type) (x :: z) (xs :: WeirdList (WeirdList z)).
Sing x -> Sing xs -> p _ xs
-> p _ (WeirdCons x xs))
-> p _ wl
elimWeirdList SWeirdNil pWeirdNil _ = pWeirdNil
elimWeirdList (SWeirdCons (x :: Sing (x :: z))
(xs :: Sing (xs :: WeirdList (WeirdList z))))
pWeirdNil pWeirdCons
= pWeirdCons @z @x @xs x xs
(elimWeirdList @(WeirdList z) @xs @p xs pWeirdNil pWeirdCons)
```
```
$ /opt/ghc/8.0.1/bin/ghci Foo.hs
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Foo.hs, interpreted )
Foo.hs:34:8: error:
• Cannot apply expression of type ‘Sing wl
-> (forall y. p x0 t3 'WeirdNil)
-> (forall z (x :: z) (xs :: WeirdList (WeirdList z)).
Sing x
-> Sing xs
-> p (WeirdList z) t2 xs
-> p z t1 ('WeirdCons x xs))
-> p a t0 wl’
to a visible type argument ‘WeirdList z’
• In the sixth argument of ‘pWeirdCons’, namely
‘(elimWeirdList @(WeirdList z) @xs @p xs pWeirdNil pWeirdCons)’
In the expression:
pWeirdCons
@z
@x
@xs
x
xs
(elimWeirdList @(WeirdList z) @xs @p xs pWeirdNil pWeirdCons)
In an equation for ‘elimWeirdList’:
elimWeirdList
(SWeirdCons (x :: Sing (x :: z))
(xs :: Sing (xs :: WeirdList (WeirdList z))))
pWeirdNil
pWeirdCons
= pWeirdCons
@z
@x
@xs
x
xs
(elimWeirdList @(WeirdList z) @xs @p xs pWeirdNil pWeirdCons)
```
But in GHC 8.0.2, 8.2.1, and HEAD, it panics to varying degrees:
```
$ /opt/ghc/8.0.2/bin/ghci Foo.hs
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Foo.hs, interpreted )
Foo.hs:24:41: error:
• Found type wildcard ‘_’ standing for ‘t0’
Where: ‘t0’ is an ambiguous type variable
‘x0’ is an ambiguous type variable
To use the inferred type, enable PartialTypeSignatures
• In the type signature:
elimWeirdList :: forall (a :: Type)
(wl :: WeirdList a)
(p :: forall (x :: Type). x -> WeirdList x -> Type).
Sing wl
-> (forall (y :: Type). p _ WeirdNil)
-> (forall (z :: Type) (x :: z) (xs :: WeirdList (WeirdList z)).
Sing x -> Sing xs -> p _ xs -> p _ (WeirdCons x xs))
-> p _ wl
• Relevant bindings include
elimWeirdList :: Sing wl
-> (forall y. p x0 t0 'WeirdNil)
-> (forall z (x :: z) (xs :: WeirdList (WeirdList z)).
Sing x
-> Sing xs -> p (WeirdList z) t1 xs -> p z t2 ('WeirdCons x xs))
-> p a t3 wl
(bound at Foo.hs:29:1)
Foo.hs:26:44: error:ghc: panic! (the 'impossible' happened)
(GHC version 8.0.2 for x86_64-unknown-linux):
No skolem info: z_a13X[sk]
```
```
$ /opt/ghc/8.2.1/bin/ghci Foo.hs
GHCi, version 8.2.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Foo.hs, interpreted )
Foo.hs:21:18: error:
• The kind of variable ‘wl1’, namely ‘WeirdList a1’,
depends on variable ‘a1’ from an inner scope
Perhaps bind ‘wl1’ sometime after binding ‘a1’
• In the type signature:
elimWeirdList :: forall (a :: Type)
(wl :: WeirdList a)
(p :: forall (x :: Type). x -> WeirdList x -> Type).
Sing wl
-> (forall (y :: Type). p _ WeirdNil)
-> (forall (z :: Type) (x :: z) (xs :: WeirdList (WeirdList z)).
Sing x -> Sing xs -> p _ xs -> p _ (WeirdCons x xs))
-> p _ wl
|
21 | elimWeirdList :: forall (a :: Type) (wl :: WeirdList a)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
Foo.hs:24:41: error:
• Found type wildcard ‘_’ standing for ‘w0’
Where: ‘w0’ is an ambiguous type variable
‘x0’ is an ambiguous type variable
To use the inferred type, enable PartialTypeSignatures
• In the type signature:
elimWeirdList :: forall (a :: Type)
(wl :: WeirdList a)
(p :: forall (x :: Type). x -> WeirdList x -> Type).
Sing wl
-> (forall (y :: Type). p _ WeirdNil)
-> (forall (z :: Type) (x :: z) (xs :: WeirdList (WeirdList z)).
Sing x -> Sing xs -> p _ xs -> p _ (WeirdCons x xs))
-> p _ wl
|
24 | -> (forall (y :: Type). p _ WeirdNil)
| ^
Foo.hs:26:44: error:ghc: panic! (the 'impossible' happened)
(GHC version 8.2.1 for x86_64-unknown-linux):
No skolem info:
z_a1sY[sk:2]
Call stack:
CallStack (from HasCallStack):
prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable
callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcErrors.hs:2653:5 in ghc:TcErrors
```
(The error messages from HEAD, at commit 791947db6db32ef7d4772a821a0823e558e3c05b, are the same as in GHC 8.2.1.)
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.0.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | #13877 |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Typed holes regression in GHC 8.0.2: No skolem info: z_a1sY[sk:2]","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[13877],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.2","keywords":["PartialTypeSignatures","TypeFamilies,","TypeInType,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"(Originally spun off from #13877.)\r\n\r\nThe following program gives a somewhat decent error message in GHC 8.0.1:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE GADTs #-}\r\n{-# LANGUAGE RankNTypes #-}\r\n{-# LANGUAGE ScopedTypeVariables #-}\r\n{-# LANGUAGE TypeApplications #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\n{-# LANGUAGE TypeInType #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ndata family Sing (a :: k)\r\n\r\ndata WeirdList :: Type -> Type where\r\n WeirdNil :: WeirdList a\r\n WeirdCons :: a -> WeirdList (WeirdList a) -> WeirdList a\r\n\r\ndata instance Sing (z :: WeirdList a) where\r\n SWeirdNil :: Sing WeirdNil\r\n SWeirdCons :: Sing w -> Sing wws -> Sing (WeirdCons w wws)\r\n\r\nelimWeirdList :: forall (a :: Type) (wl :: WeirdList a)\r\n (p :: forall (x :: Type). x -> WeirdList x -> Type).\r\n Sing wl\r\n -> (forall (y :: Type). p _ WeirdNil)\r\n -> (forall (z :: Type) (x :: z) (xs :: WeirdList (WeirdList z)).\r\n Sing x -> Sing xs -> p _ xs\r\n -> p _ (WeirdCons x xs))\r\n -> p _ wl\r\nelimWeirdList SWeirdNil pWeirdNil _ = pWeirdNil\r\nelimWeirdList (SWeirdCons (x :: Sing (x :: z))\r\n (xs :: Sing (xs :: WeirdList (WeirdList z))))\r\n pWeirdNil pWeirdCons\r\n = pWeirdCons @z @x @xs x xs\r\n (elimWeirdList @(WeirdList z) @xs @p xs pWeirdNil pWeirdCons)\r\n}}}\r\n\r\n{{{\r\n$ /opt/ghc/8.0.1/bin/ghci Foo.hs \r\nGHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Foo.hs, interpreted )\r\n\r\nFoo.hs:34:8: error:\r\n • Cannot apply expression of type ‘Sing wl\r\n -> (forall y. p x0 t3 'WeirdNil)\r\n -> (forall z (x :: z) (xs :: WeirdList (WeirdList z)).\r\n Sing x\r\n -> Sing xs\r\n -> p (WeirdList z) t2 xs\r\n -> p z t1 ('WeirdCons x xs))\r\n -> p a t0 wl’\r\n to a visible type argument ‘WeirdList z’\r\n • In the sixth argument of ‘pWeirdCons’, namely\r\n ‘(elimWeirdList @(WeirdList z) @xs @p xs pWeirdNil pWeirdCons)’\r\n In the expression:\r\n pWeirdCons\r\n @z\r\n @x\r\n @xs\r\n x\r\n xs\r\n (elimWeirdList @(WeirdList z) @xs @p xs pWeirdNil pWeirdCons)\r\n In an equation for ‘elimWeirdList’:\r\n elimWeirdList\r\n (SWeirdCons (x :: Sing (x :: z))\r\n (xs :: Sing (xs :: WeirdList (WeirdList z))))\r\n pWeirdNil\r\n pWeirdCons\r\n = pWeirdCons\r\n @z\r\n @x\r\n @xs\r\n x\r\n xs\r\n (elimWeirdList @(WeirdList z) @xs @p xs pWeirdNil pWeirdCons)\r\n}}}\r\n\r\nBut in GHC 8.0.2, 8.2.1, and HEAD, it panics to varying degrees:\r\n\r\n{{{\r\n$ /opt/ghc/8.0.2/bin/ghci Foo.hs \r\nGHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Foo.hs, interpreted )\r\n\r\nFoo.hs:24:41: error:\r\n • Found type wildcard ‘_’ standing for ‘t0’\r\n Where: ‘t0’ is an ambiguous type variable\r\n ‘x0’ is an ambiguous type variable\r\n To use the inferred type, enable PartialTypeSignatures\r\n • In the type signature:\r\n elimWeirdList :: forall (a :: Type)\r\n (wl :: WeirdList a)\r\n (p :: forall (x :: Type). x -> WeirdList x -> Type).\r\n Sing wl\r\n -> (forall (y :: Type). p _ WeirdNil)\r\n -> (forall (z :: Type) (x :: z) (xs :: WeirdList (WeirdList z)).\r\n Sing x -> Sing xs -> p _ xs -> p _ (WeirdCons x xs))\r\n -> p _ wl\r\n • Relevant bindings include\r\n elimWeirdList :: Sing wl\r\n -> (forall y. p x0 t0 'WeirdNil)\r\n -> (forall z (x :: z) (xs :: WeirdList (WeirdList z)).\r\n Sing x\r\n -> Sing xs -> p (WeirdList z) t1 xs -> p z t2 ('WeirdCons x xs))\r\n -> p a t3 wl\r\n (bound at Foo.hs:29:1)\r\n\r\nFoo.hs:26:44: error:ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.0.2 for x86_64-unknown-linux):\r\n\tNo skolem info: z_a13X[sk]\r\n}}}\r\n\r\n{{{\r\n$ /opt/ghc/8.2.1/bin/ghci Foo.hs \r\nGHCi, version 8.2.1: http://www.haskell.org/ghc/ :? for help\r\nLoaded GHCi configuration from /home/rgscott/.ghci\r\n[1 of 1] Compiling Bug ( Foo.hs, interpreted )\r\n\r\nFoo.hs:21:18: error:\r\n • The kind of variable ‘wl1’, namely ‘WeirdList a1’,\r\n depends on variable ‘a1’ from an inner scope\r\n Perhaps bind ‘wl1’ sometime after binding ‘a1’\r\n • In the type signature:\r\n elimWeirdList :: forall (a :: Type)\r\n (wl :: WeirdList a)\r\n (p :: forall (x :: Type). x -> WeirdList x -> Type).\r\n Sing wl\r\n -> (forall (y :: Type). p _ WeirdNil)\r\n -> (forall (z :: Type) (x :: z) (xs :: WeirdList (WeirdList z)).\r\n Sing x -> Sing xs -> p _ xs -> p _ (WeirdCons x xs))\r\n -> p _ wl\r\n |\r\n21 | elimWeirdList :: forall (a :: Type) (wl :: WeirdList a)\r\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...\r\n\r\nFoo.hs:24:41: error:\r\n • Found type wildcard ‘_’ standing for ‘w0’\r\n Where: ‘w0’ is an ambiguous type variable\r\n ‘x0’ is an ambiguous type variable\r\n To use the inferred type, enable PartialTypeSignatures\r\n • In the type signature:\r\n elimWeirdList :: forall (a :: Type)\r\n (wl :: WeirdList a)\r\n (p :: forall (x :: Type). x -> WeirdList x -> Type).\r\n Sing wl\r\n -> (forall (y :: Type). p _ WeirdNil)\r\n -> (forall (z :: Type) (x :: z) (xs :: WeirdList (WeirdList z)).\r\n Sing x -> Sing xs -> p _ xs -> p _ (WeirdCons x xs))\r\n -> p _ wl\r\n |\r\n24 | -> (forall (y :: Type). p _ WeirdNil)\r\n | ^\r\n\r\nFoo.hs:26:44: error:ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.2.1 for x86_64-unknown-linux):\r\n\tNo skolem info:\r\n z_a1sY[sk:2]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable\r\n callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcErrors.hs:2653:5 in ghc:TcErrors\r\n}}}\r\n\r\n(The error messages from HEAD, at commit 791947db6db32ef7d4772a821a0823e558e3c05b, are the same as in GHC 8.2.1.)","type_of_failure":"OtherFailure","blocking":[]} -->Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/13499"Panic: no skolem info" with StaticPointers and typed hole2022-03-22T09:21:03ZOtini"Panic: no skolem info" with StaticPointers and typed holeWhen compiling this minimal example:
```hs
{-# LANGUAGE StaticPointers #-}
import Data.Typeable (Typeable)
import GHC.StaticPtr (StaticPtr)
f :: Typeable a => StaticPtr (a -> a)
f = static (\a -> _)
main :: IO ()
main = return ()
```...When compiling this minimal example:
```hs
{-# LANGUAGE StaticPointers #-}
import Data.Typeable (Typeable)
import GHC.StaticPtr (StaticPtr)
f :: Typeable a => StaticPtr (a -> a)
f = static (\a -> _)
main :: IO ()
main = return ()
```
I get this output:
```
Bug.hs:8:19: error:ghc: panic! (the 'impossible' happened)
(GHC version 8.0.1 for x86_64-unknown-linux):
No skolem info: a_aJo[sk]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
Unlike similar reported bugs, this happens on both 8.0.1 and 8.0.2.
*Edit:* no need to activate GADTs.https://gitlab.haskell.org/ghc/ghc/-/issues/20063No skolem info panic involving typed hole2022-03-22T09:20:15Zsheafsam.derbyshire@gmail.comNo skolem info panic involving typed holeThe following program causes a `No skolem info` panic on GHC 9.0.1, 9.2.1, HEAD, but not on GHC 8.10.5.
```haskell
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds ...The following program causes a `No skolem info` panic on GHC 9.0.1, 9.2.1, HEAD, but not on GHC 8.10.5.
```haskell
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module Bug where
data Context where
Extend :: forall k. Context -> Context
type (:*&) :: Context -> forall k -> Context
type ctx :*& k = Extend @k ctx
data Idx ctx where
T :: Idx ctx -> Idx (ctx :*& l)
data Rn ctx1 ctx2 where
U :: Rn ctx1 ctx2 -> Rn (ctx1 :*& l) (ctx2 :*& l)
rnRename :: Rn ctx1 ctx2 -> Idx ctx3 -> Idx ctx4
rnRename (U _ ) _ = T _
rnRename _ T = undefined
```
```
[1 of 1] Compiling Bug ( src\Bug.hs, interpreted )
ghc.exe: panic! (the 'impossible' happened)
(GHC version 9.0.1:
No skolem info:
[ctx4_aBB[sk:1]]
```
The program should be rejected, and the error given with GHC 8.10.5 seems perfect:
```
[1 of 1] Compiling Bug ( src\Bug.hs, interpreted )
src\Bug.hs:26:17: error:
• The constructor ‘T’ should have 1 argument, but has been given none
• In the pattern: T
In an equation for ‘rnRename’: rnRename _ T = undefined
|
26 | rnRename _ T = undefined
| ^
```
The issue seems to be related to the presence of a typed hole on the line prior to the bogus pattern match.https://gitlab.haskell.org/ghc/ghc/-/issues/19760GHC 9.0.1+ panics (No skolem info), GHC 8.10.4 produces error message2022-03-22T09:17:44ZRyan ScottGHC 9.0.1+ panics (No skolem info), GHC 8.10.4 produces error messageIf you compile the following program with GHC 9.0.1 or later, it will panic:
```hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAG...If you compile the following program with GHC 9.0.1 or later, it will panic:
```hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module Bug where
import Data.Kind
type Sing :: k -> Type
type family Sing
type TyFun :: Type -> Type -> Type
data TyFun a b
type (~>) :: Type -> Type -> Type
type a ~> b = TyFun a b -> Type
infixr 0 ~>
type Apply :: (a ~> b) -> a -> b
type family Apply f x
type D :: Type -> Type
data D a = MkD a
type SD :: D a -> Type
data SD z where
SMkD :: Sing x -> SD (MkD x)
type instance Sing @(D a) = SD
elimD :: forall a (p :: D a ~> Type) (d :: D a).
Sing d
-> (forall (x :: a). Sing x -> Apply p (MkD x))
-> Apply p d
elimD sd k = go sd
where
go :: forall a' (d' :: D a').
Sing d' -> Apply p d'
go (SMkD sx) = k sx
```
```
$ /opt/ghc/9.0.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:43:30: error:ghc: panic! (the 'impossible' happened)
(GHC version 9.0.1:
No skolem info:
[a_axS[sk:1]]
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/Tc/Errors.hs:2810:17 in ghc:GHC.Tc.Errors
```
On the other hand, GHC 8.10.4 will produce a proper error message:
```
$ /opt/ghc/8.10.4/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:43:30: error:
• Expected kind ‘D a1’, but ‘d'’ has kind ‘D a'1’
• In the second argument of ‘Apply’, namely ‘d'’
In the type signature:
go :: forall a' (d' :: D a'). Sing d' -> Apply p d'
In an equation for ‘elimD’:
elimD sd k
= go sd
where
go :: forall a' (d' :: D a'). Sing d' -> Apply p d'
go (SMkD sx) = k sx
• Relevant bindings include
k :: forall (x :: a1). Sing x -> Apply p ('MkD x)
(bound at Bug.hs:40:10)
sd :: Sing d (bound at Bug.hs:40:7)
elimD :: Sing d
-> (forall (x :: a1). Sing x -> Apply p ('MkD x)) -> Apply p d
(bound at Bug.hs:40:1)
|
43 | Sing d' -> Apply p d'
| ^^
Bug.hs:44:22: error:
• Could not deduce: x ~~ x0
from the context: d' ~ 'MkD x
bound by a pattern with constructor:
SMkD :: forall a (x :: a). Sing x -> SD ('MkD x),
in an equation for ‘go’
at Bug.hs:44:9-15
‘x’ is a rigid type variable bound by
a pattern with constructor:
SMkD :: forall a (x :: a). Sing x -> SD ('MkD x),
in an equation for ‘go’
at Bug.hs:44:9-15
Expected type: Sing x0
Actual type: Sing x
• In the first argument of ‘k’, namely ‘sx’
In the expression: k sx
In an equation for ‘go’: go (SMkD sx) = k sx
• Relevant bindings include
sx :: Sing x (bound at Bug.hs:44:14)
go :: Sing d' -> Apply p d' (bound at Bug.hs:44:5)
k :: forall (x :: a1). Sing x -> Apply p ('MkD x)
(bound at Bug.hs:40:10)
sd :: Sing d (bound at Bug.hs:40:7)
elimD :: Sing d
-> (forall (x :: a1). Sing x -> Apply p ('MkD x)) -> Apply p d
(bound at Bug.hs:40:1)
|
44 | go (SMkD sx) = k sx
| ^^
```https://gitlab.haskell.org/ghc/ghc/-/issues/21186zlib test suite segfaults on HEAD2022-03-18T09:20:45ZRyan Scottzlib test suite segfaults on HEADTo reproduce, run:
```
$ git clone https://github.com/haskell/zlib && cd zlib/
$ cabal run test:tests -w ~/Software/ghc-9.3.20220302/bin/ghc
Resolving dependencies...
Up to date
zlib tests
property tests
decompress . compress = id...To reproduce, run:
```
$ git clone https://github.com/haskell/zlib && cd zlib/
$ cabal run test:tests -w ~/Software/ghc-9.3.20220302/bin/ghc
Resolving dependencies...
Up to date
zlib tests
property tests
decompress . compress = id (standard): OK (0.43s)
+++ OK, passed 100 tests; 124 discarded.
decompress . compress = id (Zlib -> GZipOrZLib): OK (0.37s)
+++ OK, passed 100 tests; 140 discarded.
decompress . compress = id (GZip -> GZipOrZlib): OK (0.34s)
+++ OK, passed 100 tests; 64 discarded.
concatenated gzip members: OK (0.36s)
+++ OK, passed 100 tests; 88 discarded.
multiple gzip members, boundaries (all 2-chunks): OK (0.02s)
+++ OK, passed 100 tests.
multiple gzip members, boundaries (all 3-chunks): Segmentation fault (core dumped)
```
I haven't had an opportunity to minimize the issue, but for the time being, all of the dependencies build on HEAD.9.4.1Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21080Panic in `lookupIdSubst` when making ModDetails/ModIface by hand2022-03-15T01:47:15ZGergő ÉrdiPanic in `lookupIdSubst` when making ModDetails/ModIface by handI'm synthesizing a `ModDetails`/`ModIface` directly without any original Haskell source code, and running into a problem where GHC fails during `Core` generation with an internal panic. Also, note the warning (when GHC is compiled with `...I'm synthesizing a `ModDetails`/`ModIface` directly without any original Haskell source code, and running into a problem where GHC fails during `Core` generation with an internal panic. Also, note the warning (when GHC is compiled with `-DDEBUG`) that also only shows up when the instance is used:
```
Loading module Class
Registering module Class
Registering module Enums
Loading module A
Registering module A
WARNING:
Glomming in A: [EeR :-> Once1]
Call stack:
CallStack (from HasCallStack):
warnPprTrace, called at compiler/GHC/Core/Opt/OccurAnal.hs:85:5 in ghc-lib-0.20211130-7QA7vLTw0OYJmMsraoHe3v:GHC.Core.Opt.OccurAnal
hello: panic! (the 'impossible' happened)
GHC version 9.3.20211130:
lookupIdSubst
$fMyClassFoo
InScope {}
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc-lib-0.20211130-7QA7vLTw0OYJmMsraoHe3v:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Subst.hs:260:17 in ghc-lib-0.20211130-7QA7vLTw0OYJmMsraoHe3v:GHC.Core.Subst
lookupIdSubst, called at compiler/GHC/Core/SimpleOpt.hs:240:10 in ghc-lib-0.20211130-7QA7vLTw0OYJmMsraoHe3v:GHC.Core.SimpleOpt
simple_opt_expr, called at compiler/GHC/Core/SimpleOpt.hs:225:5 in ghc-lib-0.20211130-7QA7vLTw0OYJmMsraoHe3v:GHC.Core.SimpleOpt
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
To reproduce:
1. Put attached [`Class.hs`](/uploads/a169537e55c9d38ecba15bec8be30a51/Class.hs) and [`A.hs`](/uploads/ce3d33e1eb981c405b9703bb63a4df08/A.hs) files into `input/` directory
2. Edit line 48 of `Main.hs` to point to your Hadrian stage1 directory
3. Run [`Main.hs`](/uploads/3b76b1f06548482a143f1070c495fb29/Main.hs) and observe the error messageMatthew PickeringMatthew Pickeringhttps://gitlab.haskell.org/ghc/ghc/-/issues/20636Invalid transformation around division constant folding2022-03-07T23:27:05ZBen GamariInvalid transformation around division constant foldingCompiling this Cmm program with `-O1` and GHC 8.10.7
```c
test ( bits64 buffer ) {
bits64 ret;
(ret) = prim %popcnt8(%divu(bits8[buffer + (0 :: bits64)], (2 :: bits8)));
return (ret);
}
```
Results in a `-dcmm-lint` failure:
```
C...Compiling this Cmm program with `-O1` and GHC 8.10.7
```c
test ( bits64 buffer ) {
bits64 ret;
(ret) = prim %popcnt8(%divu(bits8[buffer + (0 :: bits64)], (2 :: bits8)));
return (ret);
}
```
Results in a `-dcmm-lint` failure:
```
Cmm lint error:
in basic block c4
in MachOp application:
I8[R1] >> 1 :: W8
op is expecting: [W8, W64]
arguments provide: [I8, I8]
Program was:
{offset
c4: // global
//tick src<hi.cmm:(1,24)-(5,1)>
(_c2::I64) = call MO_PopCnt W8(I8[R1] >> 1 :: W8);
R1 = _c2::I64;
call (P64[Sp])(R1) args: 8, res: 0, upd: 8;
}
```https://gitlab.haskell.org/ghc/ghc/-/issues/18614When using Word8# functions: Error: invalid instruction suffix for `lea'2022-03-07T23:27:05ZLuite StegemanWhen using Word8# functions: Error: invalid instruction suffix for `lea'## Summary
Using some `Word8#` primitive functions results in invalid assembly. Possibly related to #18141 (which is already closed).
## Steps to reproduce
```
{-# LANGUAGE MagicHash, UnboxedTuples #-}
{-# OPTIONS_GHC -O #-}
module M...## Summary
Using some `Word8#` primitive functions results in invalid assembly. Possibly related to #18141 (which is already closed).
## Steps to reproduce
```
{-# LANGUAGE MagicHash, UnboxedTuples #-}
{-# OPTIONS_GHC -O #-}
module Main where
import GHC.Exts
main = pure ()
test :: Word8# -> Word8#
test x = x `plusWord8#` narrowWord8# 1##
```
Result with GHC HEAD ( 8.11.0.20200824 )
```
[1 of 1] Compiling Main ( UnboxedWord8.hs, UnboxedWord8.o )
/tmp/ghc3912_0/ghc_2.s: Assembler messages:
/tmp/ghc3912_0/ghc_2.s:52:0: error:
Error: invalid instruction suffix for `lea'
|
52 | leab 1(%r14),%al
| ^
`cc' failed in phase `Assembler'. (Exit code: 1)
```
Result with GHC 8.8.3
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.8.3 for x86_64-unknown-linux):
Prelude.chr: bad argument: 808989236
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
## Expected behavior
Program should compile and link without errors.
## Environment
* GHC version used: 8.8.3, 8.11.0.20200824
Linux, x86_64https://gitlab.haskell.org/ghc/ghc/-/issues/20965Applying -dannot-lint to GHC itself causes a panic2022-03-03T08:52:01ZMatthew PickeringApplying -dannot-lint to GHC itself causes a panicI tried building with:
hadrian.settings
```
stage1.ghc.ghc.hs.opts += -dcore-lint -dannot-lint
```
with build command
```
./hadrian/build --flavour=perf+ipe -j4 --freeze1 --build-root=_build-perf
```
Leads to error:
```
ghc: panic!...I tried building with:
hadrian.settings
```
stage1.ghc.ghc.hs.opts += -dcore-lint -dannot-lint
```
with build command
```
./hadrian/build --flavour=perf+ipe -j4 --freeze1 --build-root=_build-perf
```
Leads to error:
```
ghc: panic! (the 'impossible' happened)
GHC version 9.3.20220119:
idInfo
m_a1bv
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/Types/Var.hs:786:34 in ghc:GHC.Types.Var
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```Matthew PickeringMatthew Pickering