GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:03:02Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/15778GHC HEAD-only panic (zonkTcTyVarToTyVar)2019-07-07T18:03:02ZRyan ScottGHC HEAD-only panic (zonkTcTyVarToTyVar)The following program typechecks on GHC 8.0.1 through 8.6.1:
```hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUA...The following program typechecks on GHC 8.0.1 through 8.6.1:
```hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
module Bug where
import Data.Kind
type a ~> b = a -> b -> Type
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
data family Sing (a :: k)
data Flarble (a :: Type) where
MkFlarble :: Flarble Bool
data instance Sing (z :: Flarble a) where
SMkFlarble :: Sing MkFlarble
elimFlarble :: forall a
(p :: forall x. Flarble x ~> Type)
(f :: Flarble a).
Sing f
-> Apply p MkFlarble
-> Apply p f
elimFlarble s@SMkFlarble pMkFlarble =
case s of
(_ :: Sing (MkFlarble :: Flarble probablyABadIdea)) ->
pMkFlarble
```
However, it panics on GHC HEAD:
```
$ ~/Software/ghc/inplace/bin/ghc-stage2 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 8.7.20181015 for x86_64-unknown-linux):
zonkTcTyVarToTyVar
probablyABadIdea_aWn[tau:2]
Bool
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcMType.hs:1627:34 in ghc:TcMType
```
If I replace `probablyABadIdea` with `Bool`, then it typechecks again.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.5 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | highest |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"GHC HEAD-only panic (zonkTcTyVarToTyVar)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program typechecks on GHC 8.0.1 through 8.6.1:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE AllowAmbiguousTypes #-}\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\n{-# LANGUAGE TypeOperators #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\n\r\ntype a ~> b = a -> b -> Type\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\ndata family Sing (a :: k)\r\n\r\ndata Flarble (a :: Type) where\r\n MkFlarble :: Flarble Bool\r\ndata instance Sing (z :: Flarble a) where\r\n SMkFlarble :: Sing MkFlarble\r\n\r\nelimFlarble :: forall a\r\n (p :: forall x. Flarble x ~> Type)\r\n (f :: Flarble a).\r\n Sing f\r\n -> Apply p MkFlarble\r\n -> Apply p f\r\nelimFlarble s@SMkFlarble pMkFlarble =\r\n case s of\r\n (_ :: Sing (MkFlarble :: Flarble probablyABadIdea)) ->\r\n pMkFlarble\r\n}}}\r\n\r\nHowever, it panics on GHC HEAD:\r\n\r\n{{{\r\n$ ~/Software/ghc/inplace/bin/ghc-stage2 Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghc-stage2: panic! (the 'impossible' happened)\r\n (GHC version 8.7.20181015 for x86_64-unknown-linux):\r\n zonkTcTyVarToTyVar\r\n probablyABadIdea_aWn[tau:2]\r\n Bool\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcMType.hs:1627:34 in ghc:TcMType\r\n}}}\r\n\r\nIf I replace `probablyABadIdea` with `Bool`, then it typechecks again.","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15767"StgCmmEnv: variable not found" with FunctionalDependencies and FlexibleContexts2019-07-07T18:03:05Zroland"StgCmmEnv: variable not found" with FunctionalDependencies and FlexibleContexts```
{-# LANGUAGE FunctionalDependencies, FlexibleContexts #-}
module Bug where
class C a b | b -> a where f :: a -> b
y = x where
x :: (C () b, C Bool b) => b
x = f ()
```
```
$ ghc -c Bug.hs
ghc: panic! (the 'impossible' happen...```
{-# LANGUAGE FunctionalDependencies, FlexibleContexts #-}
module Bug where
class C a b | b -> a where f :: a -> b
y = x where
x :: (C () b, C Bool b) => b
x = f ()
```
```
$ ghc -c Bug.hs
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.1 for x86_64-unknown-openbsd):
StgCmmEnv: variable not found
$dC_a1lC
local binds for:
f
$tc'C:C
$tcC
$trModule
$tc'C:C1_r1mz
$tc'C:C2_r1n0
$krep_r1n1
$krep1_r1n2
$krep2_r1n3
$krep3_r1n4
$krep4_r1n5
$tcC1_r1n6
$tcC2_r1n7
$krep5_r1n8
$krep6_r1n9
$krep7_r1na
$trModule1_r1nb
$trModule2_r1nc
$trModule3_r1nd
$trModule4_r1ne
$krep8_r1nf
$krep9_r1ng
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/codeGen/StgCmmEnv.hs:149:9 in ghc:StgCmmEnv
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.1 |
| 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":"\"StgCmmEnv: variable not found\" with FunctionalDependencies and FlexibleContexts","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"\r\n{{{\r\n{-# LANGUAGE FunctionalDependencies, FlexibleContexts #-}\r\n\r\nmodule Bug where\r\n\r\nclass C a b | b -> a where f :: a -> b\r\n\r\ny = x where\r\n x :: (C () b, C Bool b) => b\r\n x = f ()\r\n}}}\r\n\r\n\r\n\r\n{{{\r\n$ ghc -c Bug.hs\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.6.1 for x86_64-unknown-openbsd):\r\n StgCmmEnv: variable not found\r\n $dC_a1lC\r\n local binds for:\r\n f\r\n $tc'C:C\r\n $tcC\r\n $trModule\r\n $tc'C:C1_r1mz\r\n $tc'C:C2_r1n0\r\n $krep_r1n1\r\n $krep1_r1n2\r\n $krep2_r1n3\r\n $krep3_r1n4\r\n $krep4_r1n5\r\n $tcC1_r1n6\r\n $tcC2_r1n7\r\n $krep5_r1n8\r\n $krep6_r1n9\r\n $krep7_r1na\r\n $trModule1_r1nb\r\n $trModule2_r1nc\r\n $trModule3_r1nd\r\n $trModule4_r1ne\r\n $krep8_r1nf\r\n $krep9_r1ng\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/codeGen/StgCmmEnv.hs:149:9 in ghc:StgCmmEnv\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.6.2https://gitlab.haskell.org/ghc/ghc/-/issues/15725Core Lint error: Trans coercion mis-match2019-07-07T18:03:14ZRyan ScottCore Lint error: Trans coercion mis-matchI discovered this when debugging #15703. The following code fails to compile with `-dcore-lint`:
```hs
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ...I discovered this when debugging #15703. The following code fails to compile with `-dcore-lint`:
```hs
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Bug where
import Data.Functor.Identity (Identity(..))
import Data.Kind (Type)
import GHC.Exts (Any)
-----
-- The important bits
-----
type instance Meth (x :: Identity a) = GenericMeth x
instance SC Identity
-------------------------------------------------------------------------------
data family Sing :: forall k. k -> Type
data instance Sing :: forall a. Identity a -> Type where
SIdentity :: Sing x -> Sing ('Identity x)
newtype Par1 p = Par1 p
data instance Sing :: forall p. Par1 p -> Type where
SPar1 :: Sing x -> Sing ('Par1 x)
type family Rep1 (f :: Type -> Type) :: Type -> Type
class PGeneric1 (f :: Type -> Type) where
type From1 (z :: f a) :: Rep1 f a
type To1 (z :: Rep1 f a) :: f a
class SGeneric1 (f :: Type -> Type) where
sFrom1 :: forall (a :: Type) (z :: f a). Sing z -> Sing (From1 z)
sTo1 :: forall (a :: Type) (r :: Rep1 f a). Sing r -> Sing (To1 r :: f a)
type instance Rep1 Identity = Par1
instance PGeneric1 Identity where
type From1 ('Identity x) = 'Par1 x
type To1 ('Par1 x) = 'Identity x
instance SGeneric1 Identity where
sFrom1 (SIdentity x) = SPar1 x
sTo1 (SPar1 x) = SIdentity x
type family GenericMeth (x :: f a) :: f a where
GenericMeth x = To1 (Meth (From1 x))
type family Meth (x :: f a) :: f a
class SC f where
sMeth :: forall a (x :: f a).
Sing x -> Sing (Meth x)
default sMeth :: forall a (x :: f a).
( SGeneric1 f, SC (Rep1 f)
, Meth x ~ GenericMeth x
)
=> Sing x -> Sing (Meth x)
sMeth sx = sTo1 (sMeth (sFrom1 sx))
dummy :: f a -> ()
dummy _ = ()
type instance Meth (x :: Par1 p) = x
instance SC Par1 where
sMeth x = x
```
```
$ /opt/ghc/8.6.1/bin/ghc -fforce-recomp Bug.hs -dcore-lint
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of Simplifier ***
<no location info>: warning:
[in body of letrec with binders x_s1Nw :: Sing (From1 x_a1Jc)]
Trans coercion mis-match: D:R:Rep1Identity[0] <a_a1Jb>_N ; Sym (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)
Rep1 Identity a_a1Jb
Par1 a_a1Jb
Rep1 Identity a_a1Jb
Par1 a_a1Jb
*** Offending Program ***
<elided>
$csMeth_a1J9 [Occ=LoopBreaker]
:: forall a (x :: Identity a). Sing x -> Sing (Meth x)
[LclId,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,
WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 100 60}]
$csMeth_a1J9
= \ (@ a_a1Jb) (@ (x_a1Jc :: Identity a_a1Jb)) ->
case heq_sel
@ (Identity a_a1Jb)
@ (Identity a_a1Jb)
@ (Meth x_a1Jc)
@ (GenericMeth x_a1Jc)
(($d~_s1Nz @ a_a1Jb @ x_a1Jc)
`cast` (((~)
<Identity a_a1Jb>_N
((To1
<Identity>_N
<a_a1Jb>_N
(Coh (Sym (D:R:MethTYPEPar1px[0]
<a_a1Jb>_N
(Coh (Sym (Coh <From1 x_a1Jc>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N)))
(D:R:Rep1Identity[0] <a_a1Jb>_N))))
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N) ; (Meth
<*>_N
(Sym (D:R:Rep1Identity[0]))
<a_a1Jb>_N
(Coh <From1 x_a1Jc>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N)))_N))_N ; (Sym (D:R:GenericMeth[0]
<Identity>_N
<a_a1Jb>_N
<x_a1Jc>_N) ; Sym (D:R:MethTYPEIdentityax[0]
<a_a1Jb>_N
<x_a1Jc>_N)))
((To1
<Identity>_N
<a_a1Jb>_N
(Coh (Sym (Coh (Sym (Coh <From1 x_a1Jc>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N)))
(D:R:Rep1Identity[0] <a_a1Jb>_N)))
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N) ; (Sym (D:R:MethTYPEPar1px[0]
<a_a1Jb>_N
(Coh (Sym (Coh <From1
x_a1Jc>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N)))
(D:R:Rep1Identity[0] <a_a1Jb>_N))) ; (Meth
<*>_N
(Sym (D:R:Rep1Identity[0]))
<a_a1Jb>_N
(Coh <From1
x_a1Jc>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N)))_N)))_N ; Sym (D:R:GenericMeth[0]
<Identity>_N
<a_a1Jb>_N
<x_a1Jc>_N)))_R ; N:~[0]
<Identity
a_a1Jb>_N <Meth
x_a1Jc>_N <GenericMeth
x_a1Jc>_N
:: (To1 (From1 x_a1Jc) ~ To1 (From1 x_a1Jc))
~R# (Meth x_a1Jc ~~ GenericMeth x_a1Jc)))
of co_a1Kd
{ __DEFAULT ->
(\ (sx_aEZ :: Sing x_a1Jc) ->
let {
x_s1Nw :: Sing (From1 x_a1Jc)
[LclId]
x_s1Nw = $csFrom1_a1Jz @ a_a1Jb @ x_a1Jc sx_aEZ } in
case x_s1Nw
`cast` ((Sing
(D:R:Rep1Identity[0] <a_a1Jb>_N)
(Coh (Sym (Coh <From1 x_a1Jc>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N ; Sym (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N))))
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)))_R ; (Nth:3
(Inst (forall (x :: Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N).
(Sing
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)
(Sym (Coh <x>_N
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N))))_R
->_R (Sing
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)
(Sym (D:R:MethTYPEPar1px[0]
<a_a1Jb>_N
<x>_N) ; (Meth
<*>_N
(Sym (D:R:Rep1Identity[0]))
<a_a1Jb>_N
(Sym (Coh <x>_N
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N))))_N))_R) (Coh <From1
x_a1Jc>_N
(Sym (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)))) ; ((Sing
(D:R:Rep1Identity[0] <a_a1Jb>_N))_R ; D:R:SingPar10[0]
<a_a1Jb>_N) (Sym (Coh <Meth
(From1
x_a1Jc)>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N))))
:: Sing (From1 x_a1Jc |> Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)
~R# R:SingPar1
a_a1Jb (Meth (From1 x_a1Jc) |> D:R:Rep1Identity[0] <a_a1Jb>_N))
of
{ SPar1 @ x_a1JZ co_a1K0 x_a195 ->
($WSIdentity @ a_a1Jb @ x_a1JZ x_a195)
`cast` ((Sing
<Identity a_a1Jb>_N
(Sym (D:R:To1IdentityaPar1[0] <a_a1Jb>_N <x_a1JZ>_N) ; (To1
<Identity>_N
<a_a1Jb>_N
(Sym (Coh (Sym (Coh <'Par1
x_a1JZ>_N
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)))
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)) ; (Coh <'Par1
x_a1JZ>_N
(Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N) ; (Sym co_a1K0 ; Coh <Meth
(From1
x_a1Jc)>_N
(D:R:Rep1Identity[0] <a_a1Jb>_N)))))_N))_R
:: Sing ('Identity x_a1JZ) ~R# Sing (To1 (Meth (From1 x_a1Jc))))
})
`cast` (<Sing x_a1Jc>_R
->_R (Sing
<Identity a_a1Jb>_N
(Sym (D:R:GenericMeth[0]
<Identity>_N <a_a1Jb>_N <x_a1Jc>_N) ; Sym co_a1Kd))_R
:: (Sing x_a1Jc -> Sing (To1 (Meth (From1 x_a1Jc))))
~R# (Sing x_a1Jc -> Sing (Meth x_a1Jc)))
}
end Rec }
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.1 |
| 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":"Core Lint error: Trans coercion mis-match","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I discovered this when debugging #15703. The following code fails to compile with `-dcore-lint`:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE DefaultSignatures #-}\r\n{-# LANGUAGE FlexibleContexts #-}\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\n{-# LANGUAGE TypeOperators #-}\r\n{-# LANGUAGE UndecidableInstances #-}\r\nmodule Bug where\r\n\r\nimport Data.Functor.Identity (Identity(..))\r\nimport Data.Kind (Type)\r\nimport GHC.Exts (Any)\r\n\r\n-----\r\n-- The important bits\r\n-----\r\n\r\ntype instance Meth (x :: Identity a) = GenericMeth x\r\ninstance SC Identity\r\n\r\n-------------------------------------------------------------------------------\r\n\r\ndata family Sing :: forall k. k -> Type\r\ndata instance Sing :: forall a. Identity a -> Type where\r\n SIdentity :: Sing x -> Sing ('Identity x)\r\n\r\nnewtype Par1 p = Par1 p\r\ndata instance Sing :: forall p. Par1 p -> Type where\r\n SPar1 :: Sing x -> Sing ('Par1 x)\r\n\r\ntype family Rep1 (f :: Type -> Type) :: Type -> Type\r\n\r\nclass PGeneric1 (f :: Type -> Type) where\r\n type From1 (z :: f a) :: Rep1 f a\r\n type To1 (z :: Rep1 f a) :: f a\r\n\r\nclass SGeneric1 (f :: Type -> Type) where\r\n sFrom1 :: forall (a :: Type) (z :: f a). Sing z -> Sing (From1 z)\r\n sTo1 :: forall (a :: Type) (r :: Rep1 f a). Sing r -> Sing (To1 r :: f a)\r\n\r\ntype instance Rep1 Identity = Par1\r\n\r\ninstance PGeneric1 Identity where\r\n type From1 ('Identity x) = 'Par1 x\r\n type To1 ('Par1 x) = 'Identity x\r\n\r\ninstance SGeneric1 Identity where\r\n sFrom1 (SIdentity x) = SPar1 x\r\n sTo1 (SPar1 x) = SIdentity x\r\n\r\ntype family GenericMeth (x :: f a) :: f a where\r\n GenericMeth x = To1 (Meth (From1 x))\r\n\r\ntype family Meth (x :: f a) :: f a\r\n\r\nclass SC f where\r\n sMeth :: forall a (x :: f a).\r\n Sing x -> Sing (Meth x)\r\n default sMeth :: forall a (x :: f a).\r\n ( SGeneric1 f, SC (Rep1 f)\r\n , Meth x ~ GenericMeth x\r\n )\r\n => Sing x -> Sing (Meth x)\r\n sMeth sx = sTo1 (sMeth (sFrom1 sx))\r\n\r\n dummy :: f a -> ()\r\n dummy _ = ()\r\n\r\ntype instance Meth (x :: Par1 p) = x\r\ninstance SC Par1 where\r\n sMeth x = x\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc -fforce-recomp Bug.hs -dcore-lint\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n*** Core Lint errors : in result of Simplifier ***\r\n<no location info>: warning:\r\n [in body of letrec with binders x_s1Nw :: Sing (From1 x_a1Jc)]\r\n Trans coercion mis-match: D:R:Rep1Identity[0] <a_a1Jb>_N ; Sym (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)\r\n Rep1 Identity a_a1Jb\r\n Par1 a_a1Jb\r\n Rep1 Identity a_a1Jb\r\n Par1 a_a1Jb\r\n*** Offending Program ***\r\n\r\n<elided>\r\n\r\n$csMeth_a1J9 [Occ=LoopBreaker]\r\n :: forall a (x :: Identity a). Sing x -> Sing (Meth x)\r\n[LclId,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,\r\n WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 100 60}]\r\n$csMeth_a1J9\r\n = \\ (@ a_a1Jb) (@ (x_a1Jc :: Identity a_a1Jb)) ->\r\n case heq_sel\r\n @ (Identity a_a1Jb)\r\n @ (Identity a_a1Jb)\r\n @ (Meth x_a1Jc)\r\n @ (GenericMeth x_a1Jc)\r\n (($d~_s1Nz @ a_a1Jb @ x_a1Jc)\r\n `cast` (((~)\r\n <Identity a_a1Jb>_N\r\n ((To1\r\n <Identity>_N\r\n <a_a1Jb>_N\r\n (Coh (Sym (D:R:MethTYPEPar1px[0]\r\n <a_a1Jb>_N\r\n (Coh (Sym (Coh <From1 x_a1Jc>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)))\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N))))\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N) ; (Meth\r\n <*>_N\r\n (Sym (D:R:Rep1Identity[0]))\r\n <a_a1Jb>_N\r\n (Coh <From1 x_a1Jc>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)))_N))_N ; (Sym (D:R:GenericMeth[0]\r\n <Identity>_N\r\n <a_a1Jb>_N\r\n <x_a1Jc>_N) ; Sym (D:R:MethTYPEIdentityax[0]\r\n <a_a1Jb>_N\r\n <x_a1Jc>_N)))\r\n ((To1\r\n <Identity>_N\r\n <a_a1Jb>_N\r\n (Coh (Sym (Coh (Sym (Coh <From1 x_a1Jc>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)))\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)))\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N) ; (Sym (D:R:MethTYPEPar1px[0]\r\n <a_a1Jb>_N\r\n (Coh (Sym (Coh <From1\r\n x_a1Jc>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)))\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N))) ; (Meth\r\n <*>_N\r\n (Sym (D:R:Rep1Identity[0]))\r\n <a_a1Jb>_N\r\n (Coh <From1\r\n x_a1Jc>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)))_N)))_N ; Sym (D:R:GenericMeth[0]\r\n <Identity>_N\r\n <a_a1Jb>_N\r\n <x_a1Jc>_N)))_R ; N:~[0]\r\n <Identity\r\n a_a1Jb>_N <Meth\r\n x_a1Jc>_N <GenericMeth\r\n x_a1Jc>_N\r\n :: (To1 (From1 x_a1Jc) ~ To1 (From1 x_a1Jc))\r\n ~R# (Meth x_a1Jc ~~ GenericMeth x_a1Jc)))\r\n of co_a1Kd\r\n { __DEFAULT ->\r\n (\\ (sx_aEZ :: Sing x_a1Jc) ->\r\n let {\r\n x_s1Nw :: Sing (From1 x_a1Jc)\r\n [LclId]\r\n x_s1Nw = $csFrom1_a1Jz @ a_a1Jb @ x_a1Jc sx_aEZ } in\r\n case x_s1Nw\r\n `cast` ((Sing\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)\r\n (Coh (Sym (Coh <From1 x_a1Jc>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N ; Sym (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N))))\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)))_R ; (Nth:3\r\n (Inst (forall (x :: Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N).\r\n (Sing\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)\r\n (Sym (Coh <x>_N\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N))))_R\r\n ->_R (Sing\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)\r\n (Sym (D:R:MethTYPEPar1px[0]\r\n <a_a1Jb>_N\r\n <x>_N) ; (Meth\r\n <*>_N\r\n (Sym (D:R:Rep1Identity[0]))\r\n <a_a1Jb>_N\r\n (Sym (Coh <x>_N\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N))))_N))_R) (Coh <From1\r\n x_a1Jc>_N\r\n (Sym (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)))) ; ((Sing\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N))_R ; D:R:SingPar10[0]\r\n <a_a1Jb>_N) (Sym (Coh <Meth\r\n (From1\r\n x_a1Jc)>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N))))\r\n :: Sing (From1 x_a1Jc |> Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)\r\n ~R# R:SingPar1\r\n a_a1Jb (Meth (From1 x_a1Jc) |> D:R:Rep1Identity[0] <a_a1Jb>_N))\r\n of\r\n { SPar1 @ x_a1JZ co_a1K0 x_a195 ->\r\n ($WSIdentity @ a_a1Jb @ x_a1JZ x_a195)\r\n `cast` ((Sing\r\n <Identity a_a1Jb>_N\r\n (Sym (D:R:To1IdentityaPar1[0] <a_a1Jb>_N <x_a1JZ>_N) ; (To1\r\n <Identity>_N\r\n <a_a1Jb>_N\r\n (Sym (Coh (Sym (Coh <'Par1\r\n x_a1JZ>_N\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)))\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N)) ; (Coh <'Par1\r\n x_a1JZ>_N\r\n (Sym (D:R:Rep1Identity[0]) <a_a1Jb>_N) ; (Sym co_a1K0 ; Coh <Meth\r\n (From1\r\n x_a1Jc)>_N\r\n (D:R:Rep1Identity[0] <a_a1Jb>_N)))))_N))_R\r\n :: Sing ('Identity x_a1JZ) ~R# Sing (To1 (Meth (From1 x_a1Jc))))\r\n })\r\n `cast` (<Sing x_a1Jc>_R\r\n ->_R (Sing\r\n <Identity a_a1Jb>_N\r\n (Sym (D:R:GenericMeth[0]\r\n <Identity>_N <a_a1Jb>_N <x_a1Jc>_N) ; Sym co_a1Kd))_R\r\n :: (Sing x_a1Jc -> Sing (To1 (Meth (From1 x_a1Jc))))\r\n ~R# (Sing x_a1Jc -> Sing (Meth x_a1Jc)))\r\n }\r\nend Rec }\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15716GHC hangs on default implementation of type family2019-07-07T18:03:19ZHeimdellGHC hangs on default implementation of type familyI have this code:
```
{-# language TypeFamilies #-}
{-# language MultiParamTypeClasses #-}
{-# language FlexibleInstances #-}
import Control.Monad.Except
class Component comp where
data Error comp :: *
type ComponentT comp :: ...I have this code:
```
{-# language TypeFamilies #-}
{-# language MultiParamTypeClasses #-}
{-# language FlexibleInstances #-}
import Control.Monad.Except
class Component comp where
data Error comp :: *
type ComponentT comp :: * -> *
type ComponentT comp = ExceptT (Error comp)
```
I expect it to either compile or fail with error.
Instead, GHC\[i\] hangs every time.
It prints
```
<interactive>:10:28: error:
```
and then hangs.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.4.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"GHC hangs on default implementation of type family","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I have this code:\r\n\r\n{{{\r\n{-# language TypeFamilies #-}\r\n{-# language MultiParamTypeClasses #-}\r\n{-# language FlexibleInstances #-}\r\n\r\nimport Control.Monad.Except\r\n\r\nclass Component comp where\r\n data Error comp :: *\r\n type ComponentT comp :: * -> *\r\n type ComponentT comp = ExceptT (Error comp)\r\n\r\n}}}\r\n\r\nI expect it to either compile or fail with error.\r\n\r\nInstead, GHC[i] hangs every time.\r\n\r\nIt prints\r\n{{{\r\n<interactive>:10:28: error:\r\n}}}\r\n\r\nand then hangs.","type_of_failure":"OtherFailure","blocking":[]} -->8.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/15709GHC panic using TypeInType with minimal source code2019-07-07T18:03:20ZjnapeGHC panic using TypeInType with minimal source codeThe following source code causes GHC 8.4.3 on 64bit Linux to panic:
```haskell
{-# LANGUAGE TypeInType #-}
module Lib where
import Data.Kind
class Contravariant f where
contramap :: (a -> b) -> f b -> f a
dimap :: (Contravariant...The following source code causes GHC 8.4.3 on 64bit Linux to panic:
```haskell
{-# LANGUAGE TypeInType #-}
module Lib where
import Data.Kind
class Contravariant f where
contramap :: (a -> b) -> f b -> f a
dimap :: (Contravariant (p :: * -> b -> p * b), Functor (p a)) => (z -> a) -> (b -> c) -> p a b -> p z c
dimap f g = contramap f . fmap g
```
I have no idea if it should compile or not, but it shouldn't do this:
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-unknown-linux):
piResultTy
k_a34u[tau:1]
*
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:947:35 in ghc:Type
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.4.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":"GHC panic using TypeInType with minimal source code","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following source code causes GHC 8.4.3 on 64bit Linux to panic:\r\n\r\n{{{#!haskell\r\n{-# LANGUAGE TypeInType #-}\r\n\r\nmodule Lib where\r\n\r\nimport Data.Kind\r\n\r\nclass Contravariant f where\r\n contramap :: (a -> b) -> f b -> f a\r\n\r\ndimap :: (Contravariant (p :: * -> b -> p * b), Functor (p a)) => (z -> a) -> (b -> c) -> p a b -> p z c\r\ndimap f g = contramap f . fmap g\r\n}}}\r\n\r\nI have no idea if it should compile or not, but it shouldn't do this:\r\n\r\n{{{\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.3 for x86_64-unknown-linux):\r\n\tpiResultTy\r\n k_a34u[tau:1]\r\n *\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Type.hs:947:35 in ghc:Type\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/15700Plugins cause GHC to panic: cannot find dynamic libraries2019-07-07T18:03:23Zsheafsam.derbyshire@gmail.comPlugins cause GHC to panic: cannot find dynamic librariesWith GHC 8.6.1 on Windows 7 x64, I seem to be getting a similar problem as in ticket #15492.
Trying to use any type-checking plugin at all causes an error. Here with the natnormalise plugin:
```
ghc.EXE: panic! (the 'impossible' happene...With GHC 8.6.1 on Windows 7 x64, I seem to be getting a similar problem as in ticket #15492.
Trying to use any type-checking plugin at all causes an error. Here with the natnormalise plugin:
```
ghc.EXE: panic! (the 'impossible' happened)
(GHC version 8.6.1 for x86_64-unknown-mingw32):
mkPluginUsage: no dylibs, tried:
C:\Code\Haskell\dylibs_bug\.stack-work\install\df4dd97d\lib\x86_64-windows-ghc-8.6.1\libHSghc-typelits-natnormalise-0.6.3-2vTVlu0GX1Q1cNTbomjNL6-ghc8.6.1.dll
C:\Users\Sam\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\bin\libHSghc-typelits-natnormalise-0.6.3-2vTVlu0GX1Q1cNTbomjNL6-ghc8.6.1.dll
C:\Users\Sam\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\lib\libHSghc-typelits-natnormalise-0.6.3-2vTVlu0GX1Q1cNTbomjNL6-ghc8.6.1.dll
GHC.TypeLits.Normalise
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler\utils\Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler\\deSugar\\DsUsage.hs:179:15 in ghc:DsUsage
```
That's with stack. I also checked with Cabal 2.4.0.1 to make sure, and indeed I get:
```
ghc.exe: panic! (the 'impossible' happened)
(GHC version 8.6.1 for x86_64-unknown-mingw32):
mkPluginUsage: no dylibs, tried:
C:\Users\Sam\AppData\Roaming\cabal\store\ghc-8.6.1\ghc-typelits-_-0.6.2-faf29727b3dbdfa09cfb6f0c881a2a227b5d2bb0\lib\libHSghc-typelits-_-0.6.2-faf29727b3dbdfa09cfb6f0c881a2a227b5d2bb0-ghc8.6.1.dll
C:\Program Files\ghc\mingw\lib\libHSghc-typelits-_-0.6.2-faf29727b3dbdfa09cfb6f0c881a2a227b5d2bb0-ghc8.6.1.dll
GHC.TypeLits.Normalise
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler\utils\Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler\\deSugar\\DsUsage.hs:179:15 in ghc:DsUsage
```
No problems with GHC 8.4.3.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.1 |
| 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":"Plugins cause GHC to panic: cannot find dynamic libraries","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"With GHC 8.6.1 on Windows 7 x64, I seem to be getting a similar problem as in ticket #15492.\r\nTrying to use any type-checking plugin at all causes an error. Here with the natnormalise plugin:\r\n\r\n{{{\r\nghc.EXE: panic! (the 'impossible' happened)\r\n (GHC version 8.6.1 for x86_64-unknown-mingw32):\r\n mkPluginUsage: no dylibs, tried:\r\nC:\\Code\\Haskell\\dylibs_bug\\.stack-work\\install\\df4dd97d\\lib\\x86_64-windows-ghc-8.6.1\\libHSghc-typelits-natnormalise-0.6.3-2vTVlu0GX1Q1cNTbomjNL6-ghc8.6.1.dll\r\nC:\\Users\\Sam\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20180531\\mingw64\\bin\\libHSghc-typelits-natnormalise-0.6.3-2vTVlu0GX1Q1cNTbomjNL6-ghc8.6.1.dll\r\nC:\\Users\\Sam\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20180531\\mingw64\\lib\\libHSghc-typelits-natnormalise-0.6.3-2vTVlu0GX1Q1cNTbomjNL6-ghc8.6.1.dll\r\n\r\n GHC.TypeLits.Normalise\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler\\utils\\Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler\\\\deSugar\\\\DsUsage.hs:179:15 in ghc:DsUsage\r\n}}}\r\n\r\n\r\nThat's with stack. I also checked with Cabal 2.4.0.1 to make sure, and indeed I get:\r\n\r\n{{{\r\nghc.exe: panic! (the 'impossible' happened)\r\n (GHC version 8.6.1 for x86_64-unknown-mingw32):\r\n mkPluginUsage: no dylibs, tried:\r\nC:\\Users\\Sam\\AppData\\Roaming\\cabal\\store\\ghc-8.6.1\\ghc-typelits-_-0.6.2-faf29727b3dbdfa09cfb6f0c881a2a227b5d2bb0\\lib\\libHSghc-typelits-_-0.6.2-faf29727b3dbdfa09cfb6f0c881a2a227b5d2bb0-ghc8.6.1.dll\r\nC:\\Program Files\\ghc\\mingw\\lib\\libHSghc-typelits-_-0.6.2-faf29727b3dbdfa09cfb6f0c881a2a227b5d2bb0-ghc8.6.1.dll\r\n\r\n GHC.TypeLits.Normalise\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler\\utils\\Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler\\\\deSugar\\\\DsUsage.hs:179:15 in ghc:DsUsage\r\n}}}\r\n\r\nNo problems with GHC 8.4.3.\r\n\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.6.2https://gitlab.haskell.org/ghc/ghc/-/issues/15695Core Lint error, from -fobject-code + defer type errors + pattern synonyms + ...2019-07-07T18:03:25ZIcelandjackCore Lint error, from -fobject-code + defer type errors + pattern synonyms + other stuffTry running this (`-fobject-code` is required) with **and** without `-dcore-lint`. I tried to minimize it but it is still hefty. This is showing it without `-dcore-lint`:
```hs
{-# Language RankNTypes, PatternSynonyms, DataKinds, PolyKi...Try running this (`-fobject-code` is required) with **and** without `-dcore-lint`. I tried to minimize it but it is still hefty. This is showing it without `-dcore-lint`:
```hs
{-# Language RankNTypes, PatternSynonyms, DataKinds, PolyKinds, GADTs, TypeOperators, MultiParamTypeClasses, TypeFamilies, TypeSynonymInstances, FlexibleInstances, InstanceSigs, FlexibleContexts #-}
{-# Options_GHC -fdefer-type-errors #-}
import Data.Kind
import Data.Type.Equality
data TyVar :: Type -> Type -> Type where
VO :: TyVar (a -> as) a
VS :: TyVar as a -> TyVar (b -> as) a
data NP :: (k -> Type) -> ([k] -> Type) where
Nil :: NP f '[]
(:*) :: f a -> NP f as -> NP f (a:as)
data NS :: (k -> Type) -> ([k] -> Type) where
Here :: f a -> NS f (a:as)
There :: NS f as -> NS f (a:as)
infixr 6 :&:
data Ctx :: Type -> Type where
E :: Ctx(Type)
(:&:) :: a -> Ctx(as) -> Ctx(a -> as)
data NA a
type SOP(kind::Type) code = NS (NP NA) code
data ApplyT(kind::Type) :: kind -> Ctx(kind) -> Type where
AO :: a -> ApplyT(Type) a E
AS :: ApplyT(ks) (f a) ctx
-> ApplyT(k -> ks) f (a:&:ctx)
from' :: ApplyT(Type -> Type -> Type) Either ctx -> NS (NP NA) '[ '[VO] ]
from' (ASSO (Left a)) = Here (a :* Nil)
from' (ASSO (Right b)) = There (Here undefined)
pattern ASSO
:: () =>
forall (ks :: Type) k (f :: k -> ks) (a1 :: k) (ks1 :: Type) k1 (f1 :: k1 -> ks1) (a2 :: k1) a3.
(kind ~ (k -> k1 -> Type), a ~~ f, b ~~ (a1 :&: a2 :&: E),
f a1 ~~ f1, f1 a2 ~~ a3) =>
a3 -> ApplyT kind a b
pattern ASSO a = AS (AS (AO a))
```
```
$ ghci -ignore-dot-ghci -fobject-code 466.hs
GHCi, version 8.7.20180828: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( 466.hs, 466.o )
466.hs:35:14: warning: [-Wdeferred-type-errors]
• Could not deduce: a2 ~ NA 'VO
from the context: ((* -> * -> *) ~ (k1 -> k2 -> *), Either ~~ f,
ctx ~~ (a2 ':&: (a3 ':&: 'E)), f a2 ~~ f1, f1 a3 ~~ a4)
bound by a pattern with pattern synonym:
ASSO :: forall kind (a :: kind) (b :: Ctx kind).
() =>
forall ks k (f :: k -> ks) (a1 :: k) ks1 k1 (f1 :: k1
-> ks1) (a2 :: k1) a3.
(kind ~ (k -> k1 -> *), a ~~ f, b ~~ (a1 ':&: (a2 ':&: 'E)),
f a1 ~~ f1, f1 a2 ~~ a3) =>
a3 -> ApplyT kind a b,
in an equation for ‘from'’
at 466.hs:35:8-21
‘a2’ is a rigid type variable bound by
a pattern with pattern synonym:
ASSO :: forall kind (a :: kind) (b :: Ctx kind).
() =>
forall ks k (f :: k -> ks) (a1 :: k) ks1 k1 (f1 :: k1
-> ks1) (a2 :: k1) a3.
(kind ~ (k -> k1 -> *), a ~~ f, b ~~ (a1 ':&: (a2 ':&: 'E)),
f a1 ~~ f1, f1 a2 ~~ a3) =>
a3 -> ApplyT kind a b,
in an equation for ‘from'’
at 466.hs:35:8-21
Expected type: a4
Actual type: Either (NA 'VO) a3
• In the pattern: Left a
In the pattern: ASSO (Left a)
In an equation for ‘from'’: from' (ASSO (Left a)) = Here (a :* Nil)
• Relevant bindings include
from' :: ApplyT (* -> * -> *) Either ctx -> NS (NP NA) '[ '[ 'VO]]
(bound at 466.hs:35:1)
|
35 | from' (ASSO (Left a)) = Here (a :* Nil)
| ^^^^^^^
466.hs:36:26: warning: [-Wdeferred-type-errors]
• Couldn't match type ‘a0 : as0’ with ‘'[]’
Expected type: NS (NP NA) '[ '[ 'VO]]
Actual type: NS (NP NA) ('[ 'VO] : a0 : as0)
• In the expression: There (Here undefined)
In an equation for ‘from'’:
from' (ASSO (Right b)) = There (Here undefined)
• Relevant bindings include
from' :: ApplyT (* -> * -> *) Either ctx -> NS (NP NA) '[ '[ 'VO]]
(bound at 466.hs:35:1)
|
36 | from' (ASSO (Right b)) = There (Here undefined)
| ^^^^^^^^^^^^^^^^^^^^^^
WARNING: file compiler/types/TyCoRep.hs, line 2378
in_scope InScope {wild_00 wild_Xl wild_Xv wild_X1m a_a1Gv ks_a1Ou
k_a1Ov f_a1Ow a_a1Ox ctx_a1Oy co_a1Oz co_a1OA co_a1OB ks_a1OC
k_a1OD f_a1OE a_a1OF ctx_a1OG co_a1OH co_a1OI co_a1OJ a_a1OK
co_a1OL co_a1OM co_a1ON as_a1Q3 a_a1Q4 ctx_a1Q5 $krep_a2XW
$krep_a2XX $krep_a2XY $krep_a2XZ $krep_a2Y0 $krep_a2Y1 $krep_a2Y2
$krep_a2Y3 $krep_a2Y4 $krep_a2Y5 $krep_a2Y6 $krep_a2Y7 $krep_a2Y8
$krep_a2Y9 $krep_a2Ya $krep_a2Yb $krep_a2Yc $krep_a2Yd $krep_a2Ye
$krep_a2Yf $krep_a2Yg $krep_a2Yh $krep_a2Yi $krep_a2Yj $krep_a2Yk
$krep_a2Yl $krep_a2Ym $krep_a2Yn $krep_a2Yo $krep_a2Yp $krep_a2Yq
$krep_a2Yr $krep_a2Ys $krep_a2Yt $krep_a2Yu $krep_a2Yv $krep_a2Yw
$krep_a2Yx $krep_a2Yy $krep_a2Yz $krep_a2YA $krep_a2YB $krep_a2YC
$krep_a2YD $krep_a2YE $krep_a2YF $krep_a2YG $krep_a2YH $krep_a2YI
$krep_a2YJ $krep_a2YK $krep_a2YL ds_d2YO ds_d2YP ds_d2YV fail_d2Z2
from' $bASSO $mASSO $tc':&: $tc':* $tc'AO $tc'AS $tc'E $tc'Here
$tc'Nil $tc'There $tc'VO $tc'VS $tcApplyT $tcCtx $tcNA $tcNP $tcNS
$tcTyVar $trModule $trModule_s2ZM $trModule_s2ZN $trModule_s2ZO
$trModule_s2ZP $krep_s2ZQ $krep_s2ZR $krep_s2ZS $krep_s2ZT
$krep_s2ZU $krep_s2ZV $krep_s2ZW $krep_s2ZX $tcTyVar_s2ZY
$tcTyVar_s2ZZ $krep_s300 $krep_s301 $krep_s302 $krep_s303
$tc'VO_s304 $tc'VO_s305 $krep_s306 $krep_s307 $tc'VS_s308
$tc'VS_s309 $tcNP_s30a $tcNP_s30b $krep_s30c $krep_s30d $krep_s30e
$krep_s30f $krep_s30g $krep_s30h $tc':*_s30i $tc':*_s30j $krep_s30k
$krep_s30l $krep_s30m $tc'Nil_s30n $tc'Nil_s30o $tcNS_s30p
$tcNS_s30q $krep_s30r $krep_s30s $krep_s30t $krep_s30u $krep_s30v
$krep_s30w $tc'Here_s30x $tc'Here_s30y $krep_s30z $krep_s30A
$krep_s30B $tc'There_s30C $tc'There_s30D $tcCtx_s30E $tcCtx_s30F
$krep_s30G $krep_s30H $krep_s30I $tc':&:_s30J $tc':&:_s30K
$krep_s30L $krep_s30M $krep_s30N $krep_s30O $krep_s30P $tc'E_s30Q
$tc'E_s30R $tcNA_s30S $tcNA_s30T $tcApplyT_s30U $tcApplyT_s30V
$krep_s30W $krep_s30X $krep_s30Y $krep_s30Z $krep_s310 $krep_s311
$tc'AS_s312 $tc'AS_s313 $krep_s314 $krep_s315 $krep_s316
$tc'AO_s317 $tc'AO_s318}
tenv [a1Ow :-> f_a1Ow, a1Ox :-> a_a1Ox, a1Oy :-> ctx_a1Oy,
a1OE :-> f_a1OE, a1OF :-> a_a1OF, a1OG :-> ctx_a1OG]
cenv [a1Oz :-> co_a1Oz, a1OA :-> co_a1OA, a1OB :-> co_a1OB,
a1OH :-> co_a1OH, a1OI :-> co_a1OI, a1OJ :-> co_a1OJ,
a1OL :-> co_a1OL, a1OM :-> co_a1OM, a1ON :-> co_a1ON]
tys [a_a1Ox ~# (NA 'VO |> Sym (Nth:2 (Sym co_a2U0)))]
cos []
needInScope [a1Ov :-> k_a1Ov, a1OD :-> k_a1OD, a1Q3 :-> as_a1Q3,
a1Q4 :-> a_a1Q4, a2U0 :-> co_a2U0]
WARNING: file compiler/types/TyCoRep.hs, line 2378
in_scope InScope {wild_00 wild_Xl wild_Xv wild_X1m a_a1Gv ks_a1Ou
k_a1Ov f_a1Ow a_a1Ox ctx_a1Oy co_a1Oz co_a1OA co_a1OB ks_a1OC
k_a1OD f_a1OE a_a1OF ctx_a1OG co_a1OH co_a1OI co_a1OJ a_a1OK
co_a1OL co_a1OM co_a1ON as_a1Q3 a_a1Q4 ctx_a1Q5 $krep_a2XW
$krep_a2XX $krep_a2XY $krep_a2XZ $krep_a2Y0 $krep_a2Y1 $krep_a2Y2
$krep_a2Y3 $krep_a2Y4 $krep_a2Y5 $krep_a2Y6 $krep_a2Y7 $krep_a2Y8
$krep_a2Y9 $krep_a2Ya $krep_a2Yb $krep_a2Yc $krep_a2Yd $krep_a2Ye
$krep_a2Yf $krep_a2Yg $krep_a2Yh $krep_a2Yi $krep_a2Yj $krep_a2Yk
$krep_a2Yl $krep_a2Ym $krep_a2Yn $krep_a2Yo $krep_a2Yp $krep_a2Yq
$krep_a2Yr $krep_a2Ys $krep_a2Yt $krep_a2Yu $krep_a2Yv $krep_a2Yw
$krep_a2Yx $krep_a2Yy $krep_a2Yz $krep_a2YA $krep_a2YB $krep_a2YC
$krep_a2YD $krep_a2YE $krep_a2YF $krep_a2YG $krep_a2YH $krep_a2YI
$krep_a2YJ $krep_a2YK $krep_a2YL ds_d2YO ds_d2YP ds_d2YV fail_d2Z2
from' $bASSO $mASSO $tc':&: $tc':* $tc'AO $tc'AS $tc'E $tc'Here
$tc'Nil $tc'There $tc'VO $tc'VS $tcApplyT $tcCtx $tcNA $tcNP $tcNS
$tcTyVar $trModule $trModule_s2ZM $trModule_s2ZN $trModule_s2ZO
$trModule_s2ZP $krep_s2ZQ $krep_s2ZR $krep_s2ZS $krep_s2ZT
$krep_s2ZU $krep_s2ZV $krep_s2ZW $krep_s2ZX $tcTyVar_s2ZY
$tcTyVar_s2ZZ $krep_s300 $krep_s301 $krep_s302 $krep_s303
$tc'VO_s304 $tc'VO_s305 $krep_s306 $krep_s307 $tc'VS_s308
$tc'VS_s309 $tcNP_s30a $tcNP_s30b $krep_s30c $krep_s30d $krep_s30e
$krep_s30f $krep_s30g $krep_s30h $tc':*_s30i $tc':*_s30j $krep_s30k
$krep_s30l $krep_s30m $tc'Nil_s30n $tc'Nil_s30o $tcNS_s30p
$tcNS_s30q $krep_s30r $krep_s30s $krep_s30t $krep_s30u $krep_s30v
$krep_s30w $tc'Here_s30x $tc'Here_s30y $krep_s30z $krep_s30A
$krep_s30B $tc'There_s30C $tc'There_s30D $tcCtx_s30E $tcCtx_s30F
$krep_s30G $krep_s30H $krep_s30I $tc':&:_s30J $tc':&:_s30K
$krep_s30L $krep_s30M $krep_s30N $krep_s30O $krep_s30P $tc'E_s30Q
$tc'E_s30R $tcNA_s30S $tcNA_s30T $tcApplyT_s30U $tcApplyT_s30V
$krep_s30W $krep_s30X $krep_s30Y $krep_s30Z $krep_s310 $krep_s311
$tc'AS_s312 $tc'AS_s313 $krep_s314 $krep_s315 $krep_s316
$tc'AO_s317 $tc'AO_s318}
tenv [a1Ow :-> f_a1Ow, a1Ox :-> a_a1Ox, a1Oy :-> ctx_a1Oy,
a1OE :-> f_a1OE, a1OF :-> a_a1OF, a1OG :-> ctx_a1OG]
cenv [a1Oz :-> co_a1Oz, a1OA :-> co_a1OA, a1OB :-> co_a1OB,
a1OH :-> co_a1OH, a1OI :-> co_a1OI, a1OJ :-> co_a1OJ,
a1OL :-> co_a1OL, a1OM :-> co_a1OM, a1ON :-> co_a1ON]
tys [a_a1Ox ~# (NA 'VO |> Sym (Nth:2 (Sym co_a2U0)))]
cos []
needInScope [a1Ov :-> k_a1Ov, a1OD :-> k_a1OD, a1Q3 :-> as_a1Q3,
a1Q4 :-> a_a1Q4, a2U0 :-> co_a2U0]
Ok, one module loaded.
Prelude Main>
```8.6.2https://gitlab.haskell.org/ghc/ghc/-/issues/15692GHC panic from pattern synonyms + deferred type errors2019-07-07T18:03:25ZIcelandjackGHC panic from pattern synonyms + deferred type errors```hs
{-# Language DataKinds, TypeOperators, PolyKinds, PatternSynonyms, GADTs #-}
{-# Options_GHC -dcore-lint -fdefer-type-errors #-}
import Data.Kind
data Ctx :: Type -> Type where
E :: Ctx(Type)
(:&:) :: a -> Ctx(as) -> Ctx(a...```hs
{-# Language DataKinds, TypeOperators, PolyKinds, PatternSynonyms, GADTs #-}
{-# Options_GHC -dcore-lint -fdefer-type-errors #-}
import Data.Kind
data Ctx :: Type -> Type where
E :: Ctx(Type)
(:&:) :: a -> Ctx(as) -> Ctx(a -> as)
data ApplyT (k::Type) :: k -> Ctx(k) -> Type where
AO :: a -> ApplyT(Type) a E
AS :: ApplyT(ks) (f a) ctx
-> ApplyT(k -> ks) f (a:&:ctx)
pattern ASSO = AS (AS (AO False))
```
```
$ ghci -ignore-dot-ghci 463.hs
hs/463.hs:16:27: warning: [-Wdeferred-type-errors]
• Couldn't match type ‘a a1 a2’ with ‘Bool’
Expected type: a3
Actual type: Bool
• In the pattern: False
In the pattern: AO False
In the pattern: AS (AO False)
|
16 | pattern ASSO = AS (AS (AO False))
| ^^^^^
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 8.7.20180828 for x86_64-unknown-linux):
urk! lookup local fingerprint
$mASSO
[iESflb :-> ($trModule, 1ca40dc83a9c879effdb760462cc9a2d),
iESgKD :-> ($tc'E, 79f67a27a14dc1bb6eecb39e4b061e2c),
iESgKF :-> ($tc':&:, 24793c0c1652ffcf92e04f47d38fa075),
iESgKH :-> ($tcCtx, a3f9358cbfe161bf59e75500d70ce0ae),
iESgKI :-> ($tc'AO, 72111d1891cb082e989c20a2191a8b4b),
iESgKK :-> ($tc'AS, ff019c04c400d5fbdd46ff8a816d4913),
iESgKM :-> ($tcApplyT, cbfe28374b4115925c7213e6330ab115)]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/iface/MkIface.hs:524:37 in ghc:MkIface
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
>
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.1 |
| 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":"GHC panic from pattern synonyms + deferred type errors","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1","keywords":["PatternSynonyms,","TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{#!hs\r\n{-# Language DataKinds, TypeOperators, PolyKinds, PatternSynonyms, GADTs #-}\r\n\r\n{-# Options_GHC -dcore-lint -fdefer-type-errors #-}\r\n\r\nimport Data.Kind\r\n\r\ndata Ctx :: Type -> Type where\r\n E :: Ctx(Type)\r\n (:&:) :: a -> Ctx(as) -> Ctx(a -> as)\r\n\r\ndata ApplyT (k::Type) :: k -> Ctx(k) -> Type where\r\n AO :: a -> ApplyT(Type) a E\r\n AS :: ApplyT(ks) (f a) ctx\r\n -> ApplyT(k -> ks) f (a:&:ctx)\r\n\r\npattern ASSO = AS (AS (AO False))\r\n}}}\r\n\r\n{{{\r\n$ ghci -ignore-dot-ghci 463.hs\r\nhs/463.hs:16:27: warning: [-Wdeferred-type-errors]\r\n • Couldn't match type ‘a a1 a2’ with ‘Bool’\r\n Expected type: a3\r\n Actual type: Bool\r\n • In the pattern: False\r\n In the pattern: AO False\r\n In the pattern: AS (AO False)\r\n |\r\n16 | pattern ASSO = AS (AS (AO False))\r\n | ^^^^^\r\nghc-stage2: panic! (the 'impossible' happened)\r\n (GHC version 8.7.20180828 for x86_64-unknown-linux):\r\n\turk! lookup local fingerprint\r\n $mASSO\r\n [iESflb :-> ($trModule, 1ca40dc83a9c879effdb760462cc9a2d),\r\n iESgKD :-> ($tc'E, 79f67a27a14dc1bb6eecb39e4b061e2c),\r\n iESgKF :-> ($tc':&:, 24793c0c1652ffcf92e04f47d38fa075),\r\n iESgKH :-> ($tcCtx, a3f9358cbfe161bf59e75500d70ce0ae),\r\n iESgKI :-> ($tc'AO, 72111d1891cb082e989c20a2191a8b4b),\r\n iESgKK :-> ($tc'AS, ff019c04c400d5fbdd46ff8a816d4913),\r\n iESgKM :-> ($tcApplyT, cbfe28374b4115925c7213e6330ab115)]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/iface/MkIface.hs:524:37 in ghc:MkIface\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\r\n> \r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.6.2https://gitlab.haskell.org/ghc/ghc/-/issues/15666Dependent type synonym in recursive type family causes GHC to panic2019-07-07T18:03:32ZtydeuDependent type synonym in recursive type family causes GHC to panic# Background
I had written the following code in Haskell (GHC):
```hs
{-# LANGUAGE
NoImplicitPrelude,
TypeInType, PolyKinds, DataKinds,
ScopedTypeVariables,
TypeFamilies,
UndecidableInstances
#-}
import Data.Kind(Type)
dat...# Background
I had written the following code in Haskell (GHC):
```hs
{-# LANGUAGE
NoImplicitPrelude,
TypeInType, PolyKinds, DataKinds,
ScopedTypeVariables,
TypeFamilies,
UndecidableInstances
#-}
import Data.Kind(Type)
data PolyType k (t :: k)
type Wrap (t :: k) = PolyType k t
type Unwrap pt = (GetType pt :: GetKind pt)
type family GetKind (pt :: Type) :: Type where
GetKind (PolyType k t) = k
type family GetType (pt :: Type) :: k where
GetType (PolyType k t) = t
```
The intention of this code is to allow me to wrap a type of an arbitrary kind
into a type (namely `PolyType`) of a single kind (namely `Type`) and then
reverse the process (i.e. unwrap it) later.
# Problem
I wanted to define a function that would recursively operate on a composite type like so:
```hs
data Composite :: a -> b -> Type
type family RecursiveWrap expr where
RecursiveWrap (Composite a b) =
Wrap (Composite (Unwrap (RecursiveWrap a)) (Unwrap (RecursiveWrap b)))
RecursiveWrap x = Wrap x
```
However, the above definition causes GHC to panic:
```
ghc.exe: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-unknown-mingw32):
cyclic evaluation in fixIO
```
# Ideas
If we inline the the `Unwrap` synoynm into the defintion of the type family
above like so:
```hs
type family RecursiveWrap expr where
RecursiveWrap (Composite a b) =
Wrap (Composite
(GetType (RecursiveWrap a) :: GetKind (RecursiveWrap a))
(GetType (RecursiveWrap a) :: GetKind (RecursiveWrap a))
)
RecursiveWrap x = Wrap x
```
GHC instead simply produces an error:
```
* Type constructor `RecursiveWrap' cannot be used here
(it is defined and used in the same recursive group)
* In the first argument of `GetKind', namely `(RecursiveWrap a)'
In the kind `GetKind (RecursiveWrap a)'
In the first argument of `Composite', namely
`(GetType (RecursiveWrap a) :: GetKind (RecursiveWrap a))'
```
As such, I suspect this has to do with the recursive type family appearing in
the kind signature when the `Unwrap` type synonym is expanded.
However, it strikes me as odd that even the above code errors. Since with the
`UndecidableInstances` extension turned on, I think that I should be able to
write recursive type families like the above. Especially given that the above
family would not loop indefinitely and thus be reducible.8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15648Core Lint error with source-level unboxed equality2019-07-07T18:03:36ZRyan ScottCore Lint error with source-level unboxed equalityI thought that we had killed `(~#)` from the source language in #15209. I could not have been more wrong. Source-level `(~#)` is alive and well, and it can cause Core Lint errors. Be afraid. Be very, very afraid.
The trick is to grab `(...I thought that we had killed `(~#)` from the source language in #15209. I could not have been more wrong. Source-level `(~#)` is alive and well, and it can cause Core Lint errors. Be afraid. Be very, very afraid.
The trick is to grab `(~#)` using Template Haskell:
```hs
module Foo where
import Language.Haskell.TH.Lib
import Language.Haskell.TH.Syntax
ueqT :: Q Type
ueqT = conT $ mkNameG_tc "ghc-prim" "GHC.Prim" "~#"
```
Once this is done, you can plop unboxed equality wherever you want into the source language. Here is a particularly mischievous example:
```hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
module Bug where
import Data.Kind (Type)
import Data.Type.Equality (type (~~))
import Foo (ueqT)
data LegitEquality :: Type -> Type -> Type where
Legit :: LegitEquality a a
data JankyEquality :: Type -> Type -> Type where
Jank :: $ueqT a b -> JankyEquality a b
unJank :: JankyEquality a b -> $ueqT a b
unJank (Jank x) = x
legitToJank :: LegitEquality a b -> JankyEquality a b
legitToJank Legit = Jank
mkLegit :: a ~~ b => LegitEquality a b
mkLegit = Legit
ueqSym :: forall (a :: Type) (b :: Type).
$ueqT a b -> $ueqT b a
ueqSym = unJank $ legitToJank $ mkLegit @b @a
```
If you compile this with optimizations, then GHC's inner demons are unleashed, which brings utter chaos when `-dcore-lint` is enabled:
```
$ /opt/ghc/8.6.1/bin/ghc -O2 -fforce-recomp Bug.hs -dcore-lint
[1 of 2] Compiling Foo ( Foo.hs, Foo.o )
[2 of 2] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of Simplifier ***
<no location info>: warning:
[in body of lambda with binder co_a5RY :: a_a5RV ~# b_a5RW]
x_a5OX :: b_a5RW ~# a_a5RV
[LclId] is out of scope
*** Offending Program ***
<elided>
ueqSym :: forall a b. (a ~# b) => b ~# a
[LclIdX,
Arity=1,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]
ueqSym
= \ (@ a_a5RV) (@ b_a5RW) (co_a5RY :: a_a5RV ~# b_a5RW) -> x_a5OX
```
-----
Obviously, this ticket is a little tongue-in-cheek, since I'm probably inviting disaster upon myself by deliberately digging around in `ghc-prim` for `(~#)`. But this does raise the question: should we allow users to do this? I used to think that there was no harm in leaving `(~#)` lying at the bottom of the catacombs that is `ghc-prim`, but this example shows that perhaps `(~#)` should be locked away for good.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.4.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":"Core Lint error with source-level unboxed equality","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I thought that we had killed `(~#)` from the source language in #15209. I could not have been more wrong. Source-level `(~#)` is alive and well, and it can cause Core Lint errors. Be afraid. Be very, very afraid.\r\n\r\nThe trick is to grab `(~#)` using Template Haskell:\r\n\r\n{{{#!hs\r\nmodule Foo where\r\n\r\nimport Language.Haskell.TH.Lib\r\nimport Language.Haskell.TH.Syntax\r\n\r\nueqT :: Q Type\r\nueqT = conT $ mkNameG_tc \"ghc-prim\" \"GHC.Prim\" \"~#\"\r\n}}}\r\n\r\nOnce this is done, you can plop unboxed equality wherever you want into the source language. Here is a particularly mischievous example:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE GADTs #-}\r\n{-# LANGUAGE KindSignatures #-}\r\n{-# LANGUAGE ScopedTypeVariables #-}\r\n{-# LANGUAGE TemplateHaskell #-}\r\n{-# LANGUAGE TypeApplications #-}\r\n{-# LANGUAGE TypeOperators #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind (Type)\r\nimport Data.Type.Equality (type (~~))\r\nimport Foo (ueqT)\r\n\r\ndata LegitEquality :: Type -> Type -> Type where\r\n Legit :: LegitEquality a a\r\n\r\ndata JankyEquality :: Type -> Type -> Type where\r\n Jank :: $ueqT a b -> JankyEquality a b\r\n\r\nunJank :: JankyEquality a b -> $ueqT a b\r\nunJank (Jank x) = x\r\n\r\nlegitToJank :: LegitEquality a b -> JankyEquality a b\r\nlegitToJank Legit = Jank\r\n\r\nmkLegit :: a ~~ b => LegitEquality a b\r\nmkLegit = Legit\r\n\r\nueqSym :: forall (a :: Type) (b :: Type).\r\n $ueqT a b -> $ueqT b a\r\nueqSym = unJank $ legitToJank $ mkLegit @b @a\r\n}}}\r\n\r\nIf you compile this with optimizations, then GHC's inner demons are unleashed, which brings utter chaos when `-dcore-lint` is enabled:\r\n\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc -O2 -fforce-recomp Bug.hs -dcore-lint \r\n[1 of 2] Compiling Foo ( Foo.hs, Foo.o )\r\n[2 of 2] Compiling Bug ( Bug.hs, Bug.o )\r\n*** Core Lint errors : in result of Simplifier ***\r\n<no location info>: warning:\r\n [in body of lambda with binder co_a5RY :: a_a5RV ~# b_a5RW]\r\n x_a5OX :: b_a5RW ~# a_a5RV\r\n [LclId] is out of scope\r\n*** Offending Program ***\r\n\r\n<elided>\r\n\r\nueqSym :: forall a b. (a ~# b) => b ~# a\r\n[LclIdX,\r\n Arity=1,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True,\r\n Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]\r\nueqSym\r\n = \\ (@ a_a5RV) (@ b_a5RW) (co_a5RY :: a_a5RV ~# b_a5RW) -> x_a5OX\r\n}}}\r\n\r\n-----\r\n\r\nObviously, this ticket is a little tongue-in-cheek, since I'm probably inviting disaster upon myself by deliberately digging around in `ghc-prim` for `(~#)`. But this does raise the question: should we allow users to do this? I used to think that there was no harm in leaving `(~#)` lying at the bottom of the catacombs that is `ghc-prim`, but this example shows that perhaps `(~#)` should be locked away for good.","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15647ghc: panic! (the 'impossible' happened)2019-07-07T18:03:36Zmonomonghc: panic! (the 'impossible' happened)```
ghc: panic! (the 'impossible' happened)
(GHC version 8.0.2 for x86_64-unknown-linux):
initTc: unsolved constraints
WC {wc_insol =
[W] ask_an9K :: t_an9J[tau:1] (CHoleCan: ask)
[W] put_an9Q :: t_an9P[tau:1] (CHole...```
ghc: panic! (the 'impossible' happened)
(GHC version 8.0.2 for x86_64-unknown-linux):
initTc: unsolved constraints
WC {wc_insol =
[W] ask_an9K :: t_an9J[tau:1] (CHoleCan: ask)
[W] put_an9Q :: t_an9P[tau:1] (CHoleCan: put)}
```
So this code derives an instance of the Decimal type incorrectly, but not sure if this is causing the error.
I have some nested records, which contain a few Decimals. I am trying to make them acidic.
```hs
instance SafeCopy (DecimalRaw a) where
putCopy (Decimal d) = contain $ safePut d
getCopy = contain $ Decimal <$> safeGet
deriveSafeCopy 0 'base ''Client
deriveSafeCopy 0 'base ''Article
deriveSafeCopy 0 'base ''ServerData
makeLenses ''ServerData
writeState :: String -> Update ServerData ()
writeState newValue
= put (ServerData newValue)
queryState :: Update ServerData String
queryState = do ServerData string <- ask
return string
makeAcidic ''ServerData ['writeState 'queryState]
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.0.2 |
| 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":"ghc: panic! (the 'impossible' happened)","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.0.2 for x86_64-unknown-linux):\r\n\tinitTc: unsolved constraints\r\n WC {wc_insol =\r\n [W] ask_an9K :: t_an9J[tau:1] (CHoleCan: ask)\r\n [W] put_an9Q :: t_an9P[tau:1] (CHoleCan: put)}\r\n}}}\r\n\r\nSo this code derives an instance of the Decimal type incorrectly, but not sure if this is causing the error.\r\n\r\nI have some nested records, which contain a few Decimals. I am trying to make them acidic.\r\n\r\n{{{#!hs\r\ninstance SafeCopy (DecimalRaw a) where\r\n putCopy (Decimal d) = contain $ safePut d\r\n getCopy = contain $ Decimal <$> safeGet\r\n\r\nderiveSafeCopy 0 'base ''Client\r\nderiveSafeCopy 0 'base ''Article\r\n\r\n\r\nderiveSafeCopy 0 'base ''ServerData\r\nmakeLenses ''ServerData\r\n\r\nwriteState :: String -> Update ServerData ()\r\nwriteState newValue\r\n = put (ServerData newValue)\r\nqueryState :: Update ServerData String\r\nqueryState = do ServerData string <- ask\r\n return string\r\n\r\nmakeAcidic ''ServerData ['writeState 'queryState]\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15629"No skolem info" panic (GHC 8.6 only)2019-07-07T18:03:40ZRyan Scott"No skolem info" panic (GHC 8.6 only)The following program:
```hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Bug wher...The following program:
```hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Bug where
import Data.Kind
import Data.Proxy
import GHC.Generics
data TyFun :: Type -> Type -> Type
type a ~> b = TyFun a b -> Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
data family Sing :: forall k. k -> Type
newtype instance Sing (f :: k1 ~> k2) =
SLambda { applySing :: forall t. Sing t -> Sing (Apply f t) }
singFun1 :: forall f. (forall t. Sing t -> Sing (Apply f t)) -> Sing f
singFun1 f = SLambda f
data From1Sym0 :: forall k (f :: k -> Type) (a :: k). f a ~> Rep1 f a
data To1Sym0 :: forall k (f :: k -> Type) (a :: k). Rep1 f a ~> f a
type family ((f :: b ~> c) :. (g :: a ~> b)) (x :: a) :: c where
(f :. g) x = Apply f (Apply g x)
data (.@#@$$$) :: forall b c a. (b ~> c) -> (a ~> b) -> (a ~> c)
type instance Apply (f .@#@$$$ g) x = (f :. g) x
(%.) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).
Sing f -> Sing g -> Sing x -> Sing ((f :. g) x)
(sf %. sg) sx = applySing sf (applySing sg sx)
(%.$$$) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).
Sing f -> Sing g -> Sing (f .@#@$$$ g)
sf %.$$$ sg = singFun1 (sf %. sg)
f :: forall (m :: Type -> Type) x. Proxy (m x) -> ()
f _ = ()
where
sFrom1Fun :: forall ab. Sing (From1Sym0 :: m ab ~> Rep1 m ab)
sFrom1Fun = undefined
sTo1Fun :: forall ab. Sing (To1Sym0 :: Rep1 m ab ~> m ab)
sTo1Fun = undefined
sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)
sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
```
Panics on GHC 8.6:
```
$ /opt/ghc/8.6.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:50:39: error:
• Expected kind ‘m z ~> Rep1 m ab1’,
but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’
• In the first argument of ‘(.@#@$$$)’, namely
‘(From1Sym0 :: m z ~> Rep1 m z)’
In the first argument of ‘Sing’, namely
‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)’
In the type signature:
sFrom1To1Fun :: forall ab.
Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)
|
50 | sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Bug.hs:51:20: error:ghc: panic! (the 'impossible' happened)
(GHC version 8.6.0.20180823 for x86_64-unknown-linux):
No skolem info:
[ab_a1UW[sk:1]]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcErrors.hs:2891:5 in ghc:TcErrors
```
But merely errors on GHC 8.4.3:
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:50:39: error:
• Expected kind ‘m z ~> Rep1 m ab2’,
but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’
• In the first argument of ‘(.@#@$$$)’, namely
‘(From1Sym0 :: m z ~> Rep1 m z)’
In the first argument of ‘Sing’, namely
‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)’
In the type signature:
sFrom1To1Fun :: forall ab.
Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab
~> Rep1 m ab)
|
50 | sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Bug.hs:51:20: error:
• Couldn't match type ‘ab1’ with ‘z1’
because type variable ‘z1’ would escape its scope
This (rigid, skolem) type variable is bound by
the type signature for:
sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)
at Bug.hs:50:5-112
Expected type: Sing From1Sym0
Actual type: Sing From1Sym0
• In the first argument of ‘(%.$$$)’, namely ‘sFrom1Fun’
In the expression: sFrom1Fun %.$$$ sTo1Fun
In an equation for ‘sFrom1To1Fun’:
sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
• Relevant bindings include
sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)
(bound at Bug.hs:51:5)
|
51 | sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
| ^^^^^^^^^
Bug.hs:51:36: error:
• Couldn't match type ‘ab’ with ‘z1’
because type variable ‘z1’ would escape its scope
This (rigid, skolem) type variable is bound by
the type signature for:
sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)
at Bug.hs:50:5-112
Expected type: Sing To1Sym0
Actual type: Sing To1Sym0
• In the second argument of ‘(%.$$$)’, namely ‘sTo1Fun’
In the expression: sFrom1Fun %.$$$ sTo1Fun
In an equation for ‘sFrom1To1Fun’:
sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
• Relevant bindings include
sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)
(bound at Bug.hs:51:5)
|
51 | sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun
| ^^^^^^^
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.6.1-beta1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"\"No skolem info\" panic (GHC 8.6 only)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.1-beta1","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE RankNTypes #-}\r\n{-# LANGUAGE ScopedTypeVariables #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\n{-# LANGUAGE TypeInType #-}\r\n{-# LANGUAGE TypeOperators #-}\r\n{-# LANGUAGE UndecidableInstances #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Proxy\r\nimport GHC.Generics\r\n\r\ndata TyFun :: Type -> Type -> Type\r\ntype a ~> b = TyFun a b -> Type\r\ninfixr 0 ~>\r\ntype family Apply (f :: k1 ~> k2) (x :: k1) :: k2\r\n\r\ndata family Sing :: forall k. k -> Type\r\nnewtype instance Sing (f :: k1 ~> k2) =\r\n SLambda { applySing :: forall t. Sing t -> Sing (Apply f t) }\r\nsingFun1 :: forall f. (forall t. Sing t -> Sing (Apply f t)) -> Sing f\r\nsingFun1 f = SLambda f\r\n\r\ndata From1Sym0 :: forall k (f :: k -> Type) (a :: k). f a ~> Rep1 f a\r\ndata To1Sym0 :: forall k (f :: k -> Type) (a :: k). Rep1 f a ~> f a\r\n\r\ntype family ((f :: b ~> c) :. (g :: a ~> b)) (x :: a) :: c where\r\n (f :. g) x = Apply f (Apply g x)\r\n\r\ndata (.@#@$$$) :: forall b c a. (b ~> c) -> (a ~> b) -> (a ~> c)\r\ntype instance Apply (f .@#@$$$ g) x = (f :. g) x\r\n\r\n(%.) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).\r\n Sing f -> Sing g -> Sing x -> Sing ((f :. g) x)\r\n(sf %. sg) sx = applySing sf (applySing sg sx)\r\n\r\n(%.$$$) :: forall a b c (f :: b ~> c) (g :: a ~> b) (x :: a).\r\n Sing f -> Sing g -> Sing (f .@#@$$$ g)\r\nsf %.$$$ sg = singFun1 (sf %. sg)\r\n\r\nf :: forall (m :: Type -> Type) x. Proxy (m x) -> ()\r\nf _ = ()\r\n where\r\n sFrom1Fun :: forall ab. Sing (From1Sym0 :: m ab ~> Rep1 m ab)\r\n sFrom1Fun = undefined\r\n\r\n sTo1Fun :: forall ab. Sing (To1Sym0 :: Rep1 m ab ~> m ab)\r\n sTo1Fun = undefined\r\n\r\n sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)\r\n sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n}}}\r\n\r\nPanics on GHC 8.6:\r\n\r\n{{{\r\n$ /opt/ghc/8.6.1/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:50:39: error:\r\n • Expected kind ‘m z ~> Rep1 m ab1’,\r\n but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’\r\n • In the first argument of ‘(.@#@$$$)’, namely\r\n ‘(From1Sym0 :: m z ~> Rep1 m z)’\r\n In the first argument of ‘Sing’, namely\r\n ‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)’\r\n In the type signature:\r\n sFrom1To1Fun :: forall ab.\r\n Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)\r\n |\r\n50 | sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)\r\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n\r\nBug.hs:51:20: error:ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.6.0.20180823 for x86_64-unknown-linux):\r\n No skolem info:\r\n [ab_a1UW[sk:1]]\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable\r\n pprPanic, called at compiler/typecheck/TcErrors.hs:2891:5 in ghc:TcErrors\r\n}}}\r\n\r\nBut merely errors on GHC 8.4.3:\r\n\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n\r\nBug.hs:50:39: error:\r\n • Expected kind ‘m z ~> Rep1 m ab2’,\r\n but ‘(From1Sym0 :: m z ~> Rep1 m z)’ has kind ‘m z ~> Rep1 m z’\r\n • In the first argument of ‘(.@#@$$$)’, namely\r\n ‘(From1Sym0 :: m z ~> Rep1 m z)’\r\n In the first argument of ‘Sing’, namely\r\n ‘(((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)’\r\n In the type signature:\r\n sFrom1To1Fun :: forall ab.\r\n Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab\r\n ~> Rep1 m ab)\r\n |\r\n50 | sFrom1To1Fun :: forall ab. Sing (((From1Sym0 :: m z ~> Rep1 m z) .@#@$$$ To1Sym0) :: Rep1 m ab ~> Rep1 m ab)\r\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n\r\nBug.hs:51:20: error:\r\n • Couldn't match type ‘ab1’ with ‘z1’\r\n because type variable ‘z1’ would escape its scope\r\n This (rigid, skolem) type variable is bound by\r\n the type signature for:\r\n sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n at Bug.hs:50:5-112\r\n Expected type: Sing From1Sym0\r\n Actual type: Sing From1Sym0\r\n • In the first argument of ‘(%.$$$)’, namely ‘sFrom1Fun’\r\n In the expression: sFrom1Fun %.$$$ sTo1Fun\r\n In an equation for ‘sFrom1To1Fun’:\r\n sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n • Relevant bindings include\r\n sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n (bound at Bug.hs:51:5)\r\n |\r\n51 | sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n | ^^^^^^^^^\r\n\r\nBug.hs:51:36: error:\r\n • Couldn't match type ‘ab’ with ‘z1’\r\n because type variable ‘z1’ would escape its scope\r\n This (rigid, skolem) type variable is bound by\r\n the type signature for:\r\n sFrom1To1Fun :: forall z1 ab3. Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n at Bug.hs:50:5-112\r\n Expected type: Sing To1Sym0\r\n Actual type: Sing To1Sym0\r\n • In the second argument of ‘(%.$$$)’, namely ‘sTo1Fun’\r\n In the expression: sFrom1Fun %.$$$ sTo1Fun\r\n In an equation for ‘sFrom1To1Fun’:\r\n sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n • Relevant bindings include\r\n sFrom1To1Fun :: Sing (From1Sym0 .@#@$$$ To1Sym0)\r\n (bound at Bug.hs:51:5)\r\n |\r\n51 | sFrom1To1Fun = sFrom1Fun %.$$$ sTo1Fun\r\n | ^^^^^^^\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15597GHC shouting: panic!2019-07-07T18:03:54ZtstrGHC shouting: panic!This program makes the impossible happen:
```hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeInType #-}
import GHC.Types
data Bug :: (f x -> Type) -> Type where
Bug :: forall
(r::h -> forall x. f x -> Type)
(a::f x)
. (r::...This program makes the impossible happen:
```hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeInType #-}
import GHC.Types
data Bug :: (f x -> Type) -> Type where
Bug :: forall
(r::h -> forall x. f x -> Type)
(a::f x)
. (r::((f x -> Type) -> Type) -> forall x. f x -> Type) Bug a
-> Bug (r::f x -> Type)
```
And asked for reporting the error:
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.4.1 for x86_64-unknown-linux):
piResultTy
k_aozeA[tau:1]
(x_aozeN[sk:2] |> {co_aozeO})
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:950:35 in ghc:Type
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.4.1 |
| 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":"GHC shouting: panic!","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.1","keywords":["TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This program makes the impossible happen:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE RankNTypes #-}\r\n{-# LANGUAGE TypeInType #-}\r\n\r\nimport GHC.Types\r\n\r\ndata Bug :: (f x -> Type) -> Type where\r\n Bug :: forall\r\n (r::h -> forall x. f x -> Type)\r\n (a::f x)\r\n . (r::((f x -> Type) -> Type) -> forall x. f x -> Type) Bug a\r\n -> Bug (r::f x -> Type)\r\n}}}\r\n\r\n\r\nAnd asked for reporting the error:\r\n\r\n{{{\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.1 for x86_64-unknown-linux):\r\n\tpiResultTy\r\n k_aozeA[tau:1]\r\n (x_aozeN[sk:2] |> {co_aozeO})\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Type.hs:950:35 in ghc:Type\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/15586Compilation panic! (the 'impossible' happened)2019-07-07T18:04:01ZsubaruruCompilation panic! (the 'impossible' happened)See attached zip for entire project causing error. I'd imagine it's pretty reproducible, just call stack build. I'm running standard lts-12.8 and it's just two small files that don't do anything yet!
Also included is panicmessage.txt sho...See attached zip for entire project causing error. I'd imagine it's pretty reproducible, just call stack build. I'm running standard lts-12.8 and it's just two small files that don't do anything yet!
Also included is panicmessage.txt showing the exact output, crucially:
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-unknown-linux):
piResultTy
*
v_XabT
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:947:35 in ghc:Type
```
Oh and sysinfo
```
uname -a
Linux @@@ 4.16.11-100.fc26.x86_64 #1 SMP Tue May 22 20:02:12 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 8.4.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Linux |
| Architecture | x86_64 (amd64) |
</details>
<!-- {"blocked_by":[],"summary":"Compilation panic! (the 'impossible' happened)","status":"New","operating_system":"Linux","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"x86_64 (amd64)","cc":[""],"type":"Bug","description":"See attached zip for entire project causing error. I'd imagine it's pretty reproducible, just call stack build. I'm running standard lts-12.8 and it's just two small files that don't do anything yet!\r\nAlso included is panicmessage.txt showing the exact output, crucially:\r\n\r\n{{{\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.3 for x86_64-unknown-linux):\r\n\tpiResultTy\r\n *\r\n v_XabT\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Type.hs:947:35 in ghc:Type\r\n\r\n}}}\r\n\r\nOh and sysinfo \r\n\r\n\r\n{{{\r\nuname -a\r\nLinux @@@ 4.16.11-100.fc26.x86_64 #1 SMP Tue May 22 20:02:12 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux\r\n}}}\r\n\r\n\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15552Infinite loop/panic with an existential type.2019-07-07T18:04:11ZhowtonotwinInfinite loop/panic with an existential type.The symptoms of this bug are quite similar to #14723, but I don't know if the cause is exactly the same, ergo a new report.
To reproduce:
1. Make `T.hs`
```hs
{-# LANGUAGE DataKinds, ExistentialQuantification, GADTs, PolyKinds, TypeOp...The symptoms of this bug are quite similar to #14723, but I don't know if the cause is exactly the same, ergo a new report.
To reproduce:
1. Make `T.hs`
```hs
{-# LANGUAGE DataKinds, ExistentialQuantification, GADTs, PolyKinds, TypeOperators #-}
module T where
import Data.Kind
data Elem :: k -> [k] -> Type where
Here :: Elem x (x : xs)
There :: Elem x xs -> Elem x (y : xs)
data EntryOfVal (v :: Type) (kvs :: [Type]) = forall (k :: Type). EntryOfVal (Elem (k, v) kvs)
```
1. Compile it with `ghc T.hs -ddump-tc-trace`
```
# etc.
checkExpectedKind
*
TYPE t_aXd[tau:1]
<*>_N
kcLHsQTyVars: not-cusk
EntryOfVal
[]
[(k_aW0 :: Type)]
[]
[k_aW0[sk:1]]
*ghc: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-apple-darwin):
kcConDecl
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
1. Append the following to `T.hs` (not minimized, sorry)
```hs
type family EntryOfValKey (eov :: EntryOfVal v kvs) :: Type where
EntryOfValKey ('EntryOfVal (_ :: Elem (k, v) kvs)) = k
type family GetEntryOfVal (eov :: EntryOfVal v kvs) :: Elem (EntryOfValKey eov, v) kvs where
GetEntryOfVal ('EntryOfVal e) = e
type family FirstEntryOfVal (v :: Type) (kvs :: [Type]) :: EntryOfVal v kvs where
FirstEntryOfVal v ((k, v) : _) = 'EntryOfVal Here
FirstEntryOfVal v (_ : kvs) = 'EntryOfVal (There (GetEntryOfVal (FirstEntryOfVal v kvs)))
```
1. Compile with a plain `ghc T.hs`
1. Wait until bored, then knock the compiler out of its infinite loop by killing it.
1. Compile again with `ghc T.hs -ddump-tc-trace`
```
# etc.
checkExpectedKind
*
TYPE t_aYg[tau:1]
<*>_N
kcLHsQTyVars: not-cuskghc: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-apple-darwin):
kcConDecl
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
Found while trying to answer [this SO question](https://stackoverflow.com/q/51944931/5684257).
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.4.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":"Infinite loop/panic with an existential type.","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The symptoms of this bug are quite similar to #14723, but I don't know if the cause is exactly the same, ergo a new report.\r\n\r\nTo reproduce:\r\n\r\n1. Make `T.hs`\r\n{{{#!hs\r\n{-# LANGUAGE DataKinds, ExistentialQuantification, GADTs, PolyKinds, TypeOperators #-}\r\nmodule T where\r\n\r\nimport Data.Kind\r\n\r\ndata Elem :: k -> [k] -> Type where\r\n Here :: Elem x (x : xs)\r\n There :: Elem x xs -> Elem x (y : xs)\r\n\r\ndata EntryOfVal (v :: Type) (kvs :: [Type]) = forall (k :: Type). EntryOfVal (Elem (k, v) kvs)\r\n}}}\r\n\r\n2. Compile it with `ghc T.hs -ddump-tc-trace`\r\n{{{\r\n# etc.\r\ncheckExpectedKind\r\n *\r\n TYPE t_aXd[tau:1]\r\n <*>_N\r\nkcLHsQTyVars: not-cusk\r\n EntryOfVal\r\n []\r\n [(k_aW0 :: Type)]\r\n []\r\n [k_aW0[sk:1]]\r\n *ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.3 for x86_64-apple-darwin):\r\n\tkcConDecl\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\n3. Append the following to `T.hs` (not minimized, sorry)\r\n{{{#!hs\r\ntype family EntryOfValKey (eov :: EntryOfVal v kvs) :: Type where\r\n EntryOfValKey ('EntryOfVal (_ :: Elem (k, v) kvs)) = k\r\ntype family GetEntryOfVal (eov :: EntryOfVal v kvs) :: Elem (EntryOfValKey eov, v) kvs where\r\n GetEntryOfVal ('EntryOfVal e) = e\r\n\r\ntype family FirstEntryOfVal (v :: Type) (kvs :: [Type]) :: EntryOfVal v kvs where\r\n FirstEntryOfVal v ((k, v) : _) = 'EntryOfVal Here\r\n FirstEntryOfVal v (_ : kvs) = 'EntryOfVal (There (GetEntryOfVal (FirstEntryOfVal v kvs)))\r\n}}}\r\n\r\n4. Compile with a plain `ghc T.hs`\r\n 1. Wait until bored, then knock the compiler out of its infinite loop by killing it.\r\n5. Compile again with `ghc T.hs -ddump-tc-trace`\r\n{{{\r\n# etc.\r\ncheckExpectedKind\r\n *\r\n TYPE t_aYg[tau:1]\r\n <*>_N\r\nkcLHsQTyVars: not-cuskghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.3 for x86_64-apple-darwin):\r\n\tkcConDecl\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nFound while trying to answer [https://stackoverflow.com/q/51944931/5684257 this SO question].","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15549Core Lint error with EmptyCase2019-07-07T18:04:11ZRyan ScottCore Lint error with EmptyCaseThe following program gives a Core Lint error on GHC 8.2.2 and later:
```hs
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE UndecidableInstances #-}
...The following program gives a Core Lint error on GHC 8.2.2 and later:
```hs
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE UndecidableInstances #-}
module Bug where
import Data.Kind
import Data.Void
data family Sing (a :: k)
data V1 :: Type -> Type
data instance Sing (z :: V1 p)
class Generic a where
type Rep a :: Type -> Type
to :: Rep a x -> a
class PGeneric a where
type To (z :: Rep a x) :: a
class SGeneric a where
sTo :: forall x (r :: Rep a x). Sing r -> Sing (To r :: a)
-----
instance Generic Void where
type Rep Void = V1
to x = case x of {}
type family EmptyCase (a :: j) :: k where
instance PGeneric Void where
type To x = EmptyCase x
instance SGeneric Void where
sTo x = case x of
```
```
$ /opt/ghc/8.4.3/bin/ghc Bug.hs -dcore-lint -fforce-recomp
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of Simplifier ***
Bug.hs:38:7: warning:
[in body of lambda with binder x_aZ8 :: Sing r_a12q]
Kind application error in
coercion ‘(Sing (D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R’
Function kind = forall k. k -> *
Arg kinds = [(V1 x_a12p, *), (r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
Bug.hs:38:7: warning:
[in body of lambda with binder x_aZ8 :: Sing r_a12q]
Kind application error in
coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’
Function kind = V1 x_a12p -> *
Arg kinds = [(r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
Bug.hs:38:7: warning:
[in body of lambda with binder x_aZ8 :: Sing r_a12q]
Kind application error in
coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’
Function kind = V1 x_a12p -> *
Arg kinds = [(r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
<no location info>: warning:
In the type ‘R:SingV1z x_a12p r_a12q’
Kind application error in type ‘R:SingV1z x_a12p r_a12q’
Function kind = forall p -> V1 p -> *
Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
<no location info>: warning:
In the type ‘R:SingV1z x_a12p r_a12q’
Kind application error in type ‘R:SingV1z x_a12p r_a12q’
Function kind = forall p -> V1 p -> *
Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]
Fun: V1 x_a12p
(r_a12q, Rep Void x_a12p)
*** Offending Program ***
<elided>
$csTo_a12n :: forall x (r :: Rep Void x). Sing r -> Sing (To r)
[LclId,
Arity=1,
Str=<L,U>x,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]
$csTo_a12n
= \ (@ x_a12p)
(@ (r_a12q :: Rep Void x_a12p))
(x_aZ8 :: Sing r_a12q) ->
case x_aZ8
`cast` ((Sing
(D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R ; D:R:SingV1z0[0]
<x_a12p>_N <r_a12q>_N
:: (Sing r_a12q :: *) ~R# (R:SingV1z x_a12p r_a12q :: *))
of nt_s13T {
}
```
GHC 8.0.2 does not appear to suffer from this Core Lint error.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------------- |
| Version | 8.4.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Core Lint error with empty closed type family","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":["TypeFamilies,","TypeInType"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The following program gives a Core Lint error on GHC 8.2.2 and later:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE EmptyCase #-}\r\n{-# LANGUAGE ScopedTypeVariables #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\n{-# LANGUAGE TypeInType #-}\r\n{-# LANGUAGE UndecidableInstances #-}\r\nmodule Bug where\r\n\r\nimport Data.Kind\r\nimport Data.Void\r\n\r\ndata family Sing (a :: k)\r\n\r\ndata V1 :: Type -> Type\r\ndata instance Sing (z :: V1 p)\r\n\r\nclass Generic a where\r\n type Rep a :: Type -> Type\r\n to :: Rep a x -> a\r\n\r\nclass PGeneric a where\r\n type To (z :: Rep a x) :: a\r\n\r\nclass SGeneric a where\r\n sTo :: forall x (r :: Rep a x). Sing r -> Sing (To r :: a)\r\n\r\n-----\r\n\r\ninstance Generic Void where\r\n type Rep Void = V1\r\n to x = case x of {}\r\n\r\ntype family EmptyCase (a :: j) :: k where\r\n\r\ninstance PGeneric Void where\r\n type To x = EmptyCase x\r\n\r\ninstance SGeneric Void where\r\n sTo x = case x of\r\n}}}\r\n{{{\r\n$ /opt/ghc/8.4.3/bin/ghc Bug.hs -dcore-lint -fforce-recomp \r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\n*** Core Lint errors : in result of Simplifier ***\r\nBug.hs:38:7: warning:\r\n [in body of lambda with binder x_aZ8 :: Sing r_a12q]\r\n Kind application error in\r\n coercion ‘(Sing (D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R’\r\n Function kind = forall k. k -> *\r\n Arg kinds = [(V1 x_a12p, *), (r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\nBug.hs:38:7: warning:\r\n [in body of lambda with binder x_aZ8 :: Sing r_a12q]\r\n Kind application error in\r\n coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’\r\n Function kind = V1 x_a12p -> *\r\n Arg kinds = [(r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\nBug.hs:38:7: warning:\r\n [in body of lambda with binder x_aZ8 :: Sing r_a12q]\r\n Kind application error in\r\n coercion ‘D:R:SingV1z0[0] <x_a12p>_N <r_a12q>_N’\r\n Function kind = V1 x_a12p -> *\r\n Arg kinds = [(r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\n<no location info>: warning:\r\n In the type ‘R:SingV1z x_a12p r_a12q’\r\n Kind application error in type ‘R:SingV1z x_a12p r_a12q’\r\n Function kind = forall p -> V1 p -> *\r\n Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\n<no location info>: warning:\r\n In the type ‘R:SingV1z x_a12p r_a12q’\r\n Kind application error in type ‘R:SingV1z x_a12p r_a12q’\r\n Function kind = forall p -> V1 p -> *\r\n Arg kinds = [(x_a12p, *), (r_a12q, Rep Void x_a12p)]\r\n Fun: V1 x_a12p\r\n (r_a12q, Rep Void x_a12p)\r\n*** Offending Program ***\r\n\r\n<elided>\r\n\r\n$csTo_a12n :: forall x (r :: Rep Void x). Sing r -> Sing (To r)\r\n[LclId,\r\n Arity=1,\r\n Str=<L,U>x,\r\n Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,\r\n WorkFree=True, Expandable=True,\r\n Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]\r\n$csTo_a12n\r\n = \\ (@ x_a12p)\r\n (@ (r_a12q :: Rep Void x_a12p))\r\n (x_aZ8 :: Sing r_a12q) ->\r\n case x_aZ8\r\n `cast` ((Sing\r\n (D:R:RepVoid[0] <x_a12p>_N) <r_a12q>_N)_R ; D:R:SingV1z0[0]\r\n <x_a12p>_N <r_a12q>_N\r\n :: (Sing r_a12q :: *) ~R# (R:SingV1z x_a12p r_a12q :: *))\r\n of nt_s13T {\r\n }\r\n}}}\r\n\r\nGHC 8.0.2 does not appear to suffer from this Core Lint error.","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15537Panic when building Crucible2019-07-07T18:04:15ZLangston BarrettPanic when building CrucibleI've encountered a panic, which GHC has asked me to report:
```
[19 of 21] Compiling Lang.Crucible.LLVM.Translation ( src/Lang/Crucible/LLVM/Translation.hs, dist/build/Lang/Crucible/LLVM/Translation.p_o )
<no location info>: error:
...I've encountered a panic, which GHC has asked me to report:
```
[19 of 21] Compiling Lang.Crucible.LLVM.Translation ( src/Lang/Crucible/LLVM/Translation.hs, dist/build/Lang/Crucible/LLVM/Translation.p_o )
<no location info>: error:
ghc: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-unknown-linux):
isUnliftedType
r_a4Zsg :: TYPE rep_a4Zsf
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:1939:10 in ghc:Type
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
This was when compiling [crucible-llvm](https://github.com/GaloisInc/crucible/tree/master/crucible-llvm) revision 186mfb7wlz with GHC 8.4.3.
I'm building in Nix with a sandbox, so this should be easily reproducible. The Nix files are available here: https://github.com/siddharthist/galois-haskell-nix/tree/ghc-bug. Just run nix-build -A haskellPackages.crucible-llvm.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.4.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":"Panic when building Crucible","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I've encountered a panic, which GHC has asked me to report:\r\n{{{\r\n[19 of 21] Compiling Lang.Crucible.LLVM.Translation ( src/Lang/Crucible/LLVM/Translation.hs, dist/build/Lang/Crucible/LLVM/Translation.p_o )\r\n\r\n<no location info>: error:\r\n ghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.3 for x86_64-unknown-linux):\r\n isUnliftedType\r\n r_a4Zsg :: TYPE rep_a4Zsf\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Type.hs:1939:10 in ghc:Type\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\r\n}}}\r\nThis was when compiling [https://github.com/GaloisInc/crucible/tree/master/crucible-llvm crucible-llvm] revision 186mfb7wlz with GHC 8.4.3.\r\n\r\nI'm building in Nix with a sandbox, so this should be easily reproducible. The Nix files are available here: https://github.com/siddharthist/galois-haskell-nix/tree/ghc-bug. Just run nix-build -A haskellPackages.crucible-llvm.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/15517-O0 and pattern synonyms triggers panic in trimJoinCont2019-07-07T18:04:21ZSimon Jakobi-O0 and pattern synonyms triggers panic in trimJoinContRunning haddock on the [\`generics-mrsop\`](https://github.com/VictorCMiraldo/generics-mrsop) package results in
```
haddock: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-unknown-linux):
completeCall
fail_av9P
Se...Running haddock on the [\`generics-mrsop\`](https://github.com/VictorCMiraldo/generics-mrsop) package results in
```
haddock: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-unknown-linux):
completeCall
fail_av9P
Select nodup wild_00
Stop[BoringCtxt] Rep Singl (El FamRoseInt) (Lkup ix CodesRoseInt)
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/simplCore/Simplify.hs:1533:9 in ghc:Simplify
```
The same problem affects 8.6.1 and HEAD, but not 8.2.2.
The panic seems to stem from [this catch-all in \`trimJoinCont\`](https://github.com/ghc/ghc/blob/64c71ce956af3af593a46ef0d615c7f6fe6ecece/compiler/simplCore/Simplify.hs#L1613).8.8.1https://gitlab.haskell.org/ghc/ghc/-/issues/15499Panic in occurence analysis phase (?), getRuntimeRep2019-07-07T18:04:28ZSerge KosyrevPanic in occurence analysis phase (?), getRuntimeRepCompiling this:
```hs
{-# LANGUAGE DataKinds, GADTs, KindSignatures #-}
module Holo ()
where
data ADT (p :: Integer) where
ADT ::
{ a :: a
, b :: Integer
} -> ADT p
foo = undefined {b=undefined}
```
1. .yields:
```
ghc...Compiling this:
```hs
{-# LANGUAGE DataKinds, GADTs, KindSignatures #-}
module Holo ()
where
data ADT (p :: Integer) where
ADT ::
{ a :: a
, b :: Integer
} -> ADT p
foo = undefined {b=undefined}
```
1. .yields:
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-unknown-linux):
getRuntimeRep
p_a29z :: Integer
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:1967:18 in ghc:Type
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
-v4 suggests this happend during the occurence analysis phase (log attached).
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------- |
| Version | 8.4.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | goldfire, simonpj |
| Operating system | Linux |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Panic in occurence analysis phase (?), getRuntimeRep","status":"New","operating_system":"Linux","component":"Compiler","related":[],"milestone":"8.4.4","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["goldfire","simonpj"],"type":"Bug","description":"Compiling this:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE DataKinds, GADTs, KindSignatures #-}\r\nmodule Holo ()\r\nwhere\r\n\r\ndata ADT (p :: Integer) where\r\n ADT ::\r\n { a :: a\r\n , b :: Integer\r\n } -> ADT p\r\n\r\nfoo = undefined {b=undefined}\r\n}}}\r\n\r\n..yields:\r\n{{{\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.3 for x86_64-unknown-linux):\r\n getRuntimeRep\r\n p_a29z :: Integer\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler/types/Type.hs:1967:18 in ghc:Type\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\n-v4 suggests this happend during the occurence analysis phase (log attached).","type_of_failure":"OtherFailure","blocking":[]} -->8.6.2Ryan ScottRyan Scotthttps://gitlab.haskell.org/ghc/ghc/-/issues/15436Compile-time panic, Prelude.!!: negative index2019-07-07T18:04:54ZpbrisbinCompile-time panic, Prelude.!!: negative indexHere is a reproduction case:
- \*ghc-repro.cabal\*\*
```
name: ghc-repro
version: 0.0.0
build-type: Simple
cabal-version: >= 1.10
library
exposed-modules:
Lib
other-modules:
Paths_ghc_repro
hs-s...Here is a reproduction case:
- \*ghc-repro.cabal\*\*
```
name: ghc-repro
version: 0.0.0
build-type: Simple
cabal-version: >= 1.10
library
exposed-modules:
Lib
other-modules:
Paths_ghc_repro
hs-source-dirs:
src
build-depends:
base
default-language: Haskell2010
```
- \*src/Lib.hs\*\*
```hs
{-# OPTIONS_GHC -v4 #-}
module Lib where
import GHC.Enum
-- | At this many elements, it panics. One fewer, it works
data USState = AL | AK | AZ | AR | CA | CO | CT | DE | FL -- | GA
-- | HI | ID | IL | IN | IA | KS | KY | LA | ME | MD
-- | MA | MI | MN | MS | MO | MT | NE | NV | NH | NJ
-- | NM | NY | NC | ND | OH | OK | OR | PA | RI | SC
-- | SD | TN | TX | UT | VT | VA | WA | WV | WI | WY
-- | DC | PR | VI | AS | GU | MP | AA | AE | AP
deriving (Eq, Show, Ord, Bounded, Read, Enum)
data USStateOrIntl = International | US USState
instance Enum USStateOrIntl where
fromEnum International = 0
fromEnum (US s) = 1 + fromEnum s
enumFrom = boundedEnumFrom
enumFromThen = boundedEnumFromThen
toEnum 0 = International
toEnum i = US . toEnum $ i - 1
instance Bounded USStateOrIntl where
minBound = International
maxBound = US maxBound
```
- \*Results\*\*:
```
ghc-repro-0.0.0: build (lib)
Preprocessing library for ghc-repro-0.0.0..
Building library for ghc-repro-0.0.0..
Running phase HsPp HsSrcFile
compile: input file src/Lib.hs
*** Checking old interface for ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib (use -ddump-hi-diffs for more details):
[1 of 2] Compiling Lib ( src/Lib.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Lib.o )
*** Parser [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]:
!!! Parser [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]: finished in 8.31 milliseconds, allocated 17.533 megabytes
*** Renamer/typechecker [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]:
!!! Renamer/typechecker [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]: finished in 354.49 milliseconds, allocated 312.556 megabytes
*** Desugar [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]:
Result size of Desugar (after optimization)
= {terms: 752, types: 352, coercions: 33, joins: 1/4}
!!! Desugar [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]: finished in 142.79 milliseconds, allocated 226.278 megabytes
*** Simplifier [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]:
Result size of Simplifier iteration=1
= {terms: 1,222, types: 790, coercions: 143, joins: 1/3}
Result size of Simplifier iteration=2
= {terms: 1,219, types: 788, coercions: 126, joins: 0/1}
Result size of Simplifier
= {terms: 1,217, types: 786, coercions: 123, joins: 0/1}
!!! Simplifier [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]: finished in 374.08 milliseconds, allocated 587.256 megabytes
*** Specialise [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]:
Result size of Specialise
= {terms: 1,217, types: 786, coercions: 123, joins: 0/1}
!!! Specialise [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]: finished in 154.05 milliseconds, allocated 235.323 megabytes
*** Float out(FOS {Lam = Just 0,
Consts = True,
OverSatApps = False}) [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]:
Result size of Float out(FOS {Lam = Just 0,
Consts = True,
OverSatApps = False})
= {terms: 1,551, types: 1,410, coercions: 123, joins: 0/0}
!!! Float out(FOS {Lam = Just 0,
Consts = True,
OverSatApps = False}) [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]: finished in 6.24 milliseconds, allocated 5.556 megabytes
*** Simplifier [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]:
Result size of Simplifier iteration=1
= {terms: 1,667, types: 1,082, coercions: 123, joins: 7/19}
ghc: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-unknown-linux):
Prelude.!!: negative index
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
The above output was produced through my normal tooling, so
```
stack build --resolver lts-12.2 --pedantic
```
To rule out stack, I was also able to reproduce the panic with plain cabal using this \*\*Dockerfile\*\*:
```
FROM haskell:8.4.3
RUN mkdir /src
WORKDIR /src
COPY ghc-repro.cabal /src/ghc-repo.cabal
COPY src/Lib.hs /src/src/Lib.hs
RUN cabal build
```
```
docker build --tag ghc-repro .
```
It still panics, but the output is different and much larger so I'll leave it here: https://8n1.org/13499/5c92
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.4.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":"Compile-time panic, Prelude.!!: negative index","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Here is a reproduction case:\r\n\r\n**ghc-repro.cabal**\r\n\r\n{{{\r\nname: ghc-repro\r\nversion: 0.0.0\r\nbuild-type: Simple\r\ncabal-version: >= 1.10\r\n\r\nlibrary\r\n exposed-modules:\r\n Lib\r\n other-modules:\r\n Paths_ghc_repro\r\n hs-source-dirs:\r\n src\r\n build-depends:\r\n base\r\n default-language: Haskell2010\r\n}}}\r\n\r\n**src/Lib.hs**\r\n\r\n{{{#!hs\r\n{-# OPTIONS_GHC -v4 #-}\r\nmodule Lib where\r\n\r\nimport GHC.Enum\r\n\r\n-- | At this many elements, it panics. One fewer, it works\r\ndata USState = AL | AK | AZ | AR | CA | CO | CT | DE | FL -- | GA\r\n -- | HI | ID | IL | IN | IA | KS | KY | LA | ME | MD\r\n -- | MA | MI | MN | MS | MO | MT | NE | NV | NH | NJ\r\n -- | NM | NY | NC | ND | OH | OK | OR | PA | RI | SC\r\n -- | SD | TN | TX | UT | VT | VA | WA | WV | WI | WY\r\n -- | DC | PR | VI | AS | GU | MP | AA | AE | AP\r\n deriving (Eq, Show, Ord, Bounded, Read, Enum)\r\n\r\ndata USStateOrIntl = International | US USState\r\n\r\ninstance Enum USStateOrIntl where\r\n fromEnum International = 0\r\n fromEnum (US s) = 1 + fromEnum s\r\n enumFrom = boundedEnumFrom\r\n enumFromThen = boundedEnumFromThen\r\n toEnum 0 = International\r\n toEnum i = US . toEnum $ i - 1\r\n\r\ninstance Bounded USStateOrIntl where\r\n minBound = International\r\n maxBound = US maxBound\r\n}}}\r\n\r\n\r\n**Results**:\r\n\r\n{{{\r\nghc-repro-0.0.0: build (lib)\r\nPreprocessing library for ghc-repro-0.0.0..\r\nBuilding library for ghc-repro-0.0.0..\r\nRunning phase HsPp HsSrcFile\r\ncompile: input file src/Lib.hs\r\n*** Checking old interface for ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib (use -ddump-hi-diffs for more details):\r\n[1 of 2] Compiling Lib ( src/Lib.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Lib.o )\r\n*** Parser [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]:\r\n!!! Parser [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]: finished in 8.31 milliseconds, allocated 17.533 megabytes\r\n*** Renamer/typechecker [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]:\r\n!!! Renamer/typechecker [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]: finished in 354.49 milliseconds, allocated 312.556 megabytes\r\n*** Desugar [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]:\r\nResult size of Desugar (after optimization)\r\n = {terms: 752, types: 352, coercions: 33, joins: 1/4}\r\n!!! Desugar [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]: finished in 142.79 milliseconds, allocated 226.278 megabytes\r\n*** Simplifier [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]:\r\nResult size of Simplifier iteration=1\r\n = {terms: 1,222, types: 790, coercions: 143, joins: 1/3}\r\nResult size of Simplifier iteration=2\r\n = {terms: 1,219, types: 788, coercions: 126, joins: 0/1}\r\nResult size of Simplifier\r\n = {terms: 1,217, types: 786, coercions: 123, joins: 0/1}\r\n!!! Simplifier [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]: finished in 374.08 milliseconds, allocated 587.256 megabytes\r\n*** Specialise [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]:\r\nResult size of Specialise\r\n = {terms: 1,217, types: 786, coercions: 123, joins: 0/1}\r\n!!! Specialise [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]: finished in 154.05 milliseconds, allocated 235.323 megabytes\r\n*** Float out(FOS {Lam = Just 0,\r\n Consts = True,\r\n OverSatApps = False}) [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]:\r\nResult size of Float out(FOS {Lam = Just 0,\r\n Consts = True,\r\n OverSatApps = False})\r\n = {terms: 1,551, types: 1,410, coercions: 123, joins: 0/0}\r\n!!! Float out(FOS {Lam = Just 0,\r\n Consts = True,\r\n OverSatApps = False}) [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]: finished in 6.24 milliseconds, allocated 5.556 megabytes\r\n*** Simplifier [ghc-repro-0.0.0-K1NxTAQg5MjG2d3fZc1tOj:Lib]:\r\nResult size of Simplifier iteration=1\r\n = {terms: 1,667, types: 1,082, coercions: 123, joins: 7/19}\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.3 for x86_64-unknown-linux):\r\n\tPrelude.!!: negative index\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nThe above output was produced through my normal tooling, so\r\n\r\n{{{\r\nstack build --resolver lts-12.2 --pedantic\r\n}}}\r\n\r\nTo rule out stack, I was also able to reproduce the panic with plain cabal using this **Dockerfile**:\r\n\r\n{{{\r\nFROM haskell:8.4.3\r\nRUN mkdir /src\r\nWORKDIR /src\r\nCOPY ghc-repro.cabal /src/ghc-repo.cabal\r\nCOPY src/Lib.hs /src/src/Lib.hs\r\nRUN cabal build\r\n}}}\r\n\r\n{{{\r\ndocker build --tag ghc-repro .\r\n}}}\r\n\r\nIt still panics, but the output is different and much larger so I'll leave it here: https://8n1.org/13499/5c92","type_of_failure":"OtherFailure","blocking":[]} -->8.4.4