GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2023-05-08T16:21:36Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/23229Panic with orphan instance on 9.02023-05-08T16:21:36ZKrzysztof GogolewskiPanic with orphan instance on 9.0This is a bug in 9.0 that is apparently fixed in 9.2+. However, it hasn't been reported so far, so I'm ticketing it just in case.
Given one-line `Main.hs`
```haskell
instance Num Bool
```
load `ghci -this-unit-id my-package -Wno-missi...This is a bug in 9.0 that is apparently fixed in 9.2+. However, it hasn't been reported so far, so I'm ticketing it just in case.
Given one-line `Main.hs`
```haskell
instance Num Bool
```
load `ghci -this-unit-id my-package -Wno-missing-methods Main` and use `:l Main`:
```
$ ghci -this-unit-id my-package -Wno-missing-methods Main
GHCi, version 9.0.2: https://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( Main.hs, interpreted )
Failed to load interface for ‘Main’
no unit id matching ‘main’ was found
ghci> :l Main
[1 of 1] Compiling Main ( Main.hs, interpreted )
ghc: panic! (the 'impossible' happened)
(GHC version 9.0.2:
lookupVers1
Main $fNumBool
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Outputable.hs:1230:37 in ghc:GHC.Utils.Outputable
pprPanic, called at compiler/GHC/Iface/Recomp.hs:1455:19 in ghc:GHC.Iface.Recomp
```
Credits to Dominic Steinitz for the initial report.9.2.1Rodrigo MesquitaRodrigo Mesquitahttps://gitlab.haskell.org/ghc/ghc/-/issues/202109.2.1 RC1 build panics on ppc64le Linux2021-08-29T19:53:16ZJens Petersen9.2.1 RC1 build panics on ppc64le Linux## Summary
(I appreciate that 9.2.1 RC1 hasn't been officially announced yet: its upload was picked up by [release-monitor.org](https://release-monitoring.org/project/906/), so I keenly started to test building for Fedora.)
Building gh...## Summary
(I appreciate that 9.2.1 RC1 hasn't been officially announced yet: its upload was picked up by [release-monitor.org](https://release-monitoring.org/project/906/), so I keenly started to test building for Fedora.)
Building ghc-9.2.0.20210806 on ppc64le with Fedora 35 ppc64le panics for me:
```
(GHC version 9.2.0.20210806:
RegAllocLinear.getFreeRegs: Bad register class
F
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs:51:19 in ghc:GHC.CmmToAsm.Reg.Linear.PPC
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
make[1]: *** [rts/ghc.mk:325: rts/dist/build/StgMiscClosures.o] Error 1
ghc-stage1: panic! (the 'impossible' happened)
```
## Steps to reproduce
Build ghc-9.2.0.20210806 on ppc64le with ghc-8.10.5
https://koji.fedoraproject.org/koji/taskinfo?taskID=73515727
Full build.log: https://kojipkgs.fedoraproject.org//work/tasks/5727/73515727/build.log (available for 2 weeks)
```
"inplace/bin/ghc-stage1" -optc-Wall -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Wno-aggregate-return -optc-Iincludes -optc-Iincludes/dist -optc-Iincludes/dist-derivedconstants/header -optc-Iincludes/dist-ghcconstants/header -optc-Iincludes/dist-install/build -optc-Irts -optc-Irts/dist/build -optc-DCOMPILING_RTS -optc-DFS_NAMESPACE=rts -optc-DUSE_LIBFFI_FOR_ADJUSTORS -optc-fno-strict-aliasing -optc-fno-common -optc-Irts/dist/build/./autogen -optc-Werror=unused-but-set-variable -optc-Wno-error=inline -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DRtsWay=\"rts_v\" -optc-ffunction-sections -optc-fdata-sections -static -H32m -O -Wall -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Iincludes/dist-install/build -Irts -Irts/dist/build -DCOMPILING_RTS -DFS_NAMESPACE=rts -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/WSDeque.c -o rts/dist/build/WSDeque.o
"inplace/bin/ghc-stage1" -optc-Wall -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Wno-aggregate-return -optc-Iincludes -optc-Iincludes/dist -optc-Iincludes/dist-derivedconstants/header -optc-Iincludes/dist-ghcconstants/header -optc-Iincludes/dist-install/build -optc-Irts -optc-Irts/dist/build -optc-DCOMPILING_RTS -optc-DFS_NAMESPACE=rts -optc-DUSE_LIBFFI_FOR_ADJUSTORS -optc-fno-strict-aliasing -optc-fno-common -optc-Irts/dist/build/./autogen -optc-Werror=unused-but-set-variable -optc-Wno-error=inline -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DRtsWay=\"rts_v\" -optc-ffunction-sections -optc-fdata-sections -static -H32m -O -Wall -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Iincludes/dist-install/build -Irts -Irts/dist/build -DCOMPILING_RTS -DFS_NAMESPACE=rts -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/Weak.c -o rts/dist/build/Weak.o
"inplace/bin/ghc-stage1" -optc-Wall -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Wno-aggregate-return -optc-Iincludes -optc-Iincludes/dist -optc-Iincludes/dist-derivedconstants/header -optc-Iincludes/dist-ghcconstants/header -optc-Iincludes/dist-install/build -optc-Irts -optc-Irts/dist/build -optc-DCOMPILING_RTS -optc-DFS_NAMESPACE=rts -optc-DUSE_LIBFFI_FOR_ADJUSTORS -optc-fno-strict-aliasing -optc-fno-common -optc-Irts/dist/build/./autogen -optc-Werror=unused-but-set-variable -optc-Wno-error=inline -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DRtsWay=\"rts_v\" -optc-ffunction-sections -optc-fdata-sections -static -H32m -O -Wall -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Iincludes/dist-install/build -Irts -Irts/dist/build -DCOMPILING_RTS -DFS_NAMESPACE=rts -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/fs.c -o rts/dist/build/fs.o
"inplace/bin/mkdirhier" rts/dist/build/hooks//.
"inplace/bin/mkdirhier" rts/dist/build/sm//.
"inplace/bin/mkdirhier" rts/dist/build/eventlog//.
"inplace/bin/mkdirhier" rts/dist/build/linker//.
"inplace/bin/mkdirhier" rts/dist/build/linker/macho//.
"inplace/bin/mkdirhier" rts/dist/build/posix//.
"inplace/bin/ghc-stage1" -optc-Wall -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Wno-aggregate-return -optc-Iincludes -optc-Iincludes/dist -optc-Iincludes/dist-derivedconstants/header -optc-Iincludes/dist-ghcconstants/header -optc-Iincludes/dist-install/build -optc-Irts -optc-Irts/dist/build -optc-DCOMPILING_RTS -optc-DFS_NAMESPACE=rts -optc-DUSE_LIBFFI_FOR_ADJUSTORS -optc-fno-strict-aliasing -optc-fno-common -optc-Irts/dist/build/./autogen -optc-Werror=unused-but-set-variable -optc-Wno-error=inline -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DRtsWay=\"rts_v\" -optc-ffunction-sections -optc-fdata-sections -static -H32m -O -Wall -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Iincludes/dist-install/build -Irts -Irts/dist/build -DCOMPILING_RTS -DFS_NAMESPACE=rts -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/StgCRunAsm.S -o rts/dist/build/StgCRunAsm.o
"inplace/bin/ghc-stage1" -static -H32m -O -Wall -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Iincludes/dist-install/build -Irts -Irts/dist/build -DCOMPILING_RTS -DFS_NAMESPACE=rts -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/Apply.cmm -o rts/dist/build/Apply.o
"inplace/bin/ghc-stage1" -static -H32m -O -Wall -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Iincludes/dist-install/build -Irts -Irts/dist/build -DCOMPILING_RTS -DFS_NAMESPACE=rts -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/Compact.cmm -o rts/dist/build/Compact.o
"inplace/bin/ghc-stage1" -static -H32m -O -Wall -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Iincludes/dist-install/build -Irts -Irts/dist/build -DCOMPILING_RTS -DFS_NAMESPACE=rts -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/Exception.cmm -o rts/dist/build/Exception.o
"inplace/bin/ghc-stage1" -static -H32m -O -Wall -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Iincludes/dist-install/build -Irts -Irts/dist/build -DCOMPILING_RTS -DFS_NAMESPACE=rts -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/HeapStackCheck.cmm -o rts/dist/build/HeapStackCheck.o
"inplace/bin/ghc-stage1" -static -H32m -O -Wall -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Iincludes/dist-install/build -Irts -Irts/dist/build -DCOMPILING_RTS -DFS_NAMESPACE=rts -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/PrimOps.cmm -o rts/dist/build/PrimOps.o
"inplace/bin/ghc-stage1" -static -H32m -O -Wall -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Iincludes/dist-install/build -Irts -Irts/dist/build -DCOMPILING_RTS -DFS_NAMESPACE=rts -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/StgMiscClosures.cmm -o rts/dist/build/StgMiscClosures.o
"inplace/bin/ghc-stage1" -static -H32m -O -Wall -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Iincludes/dist-install/build -Irts -Irts/dist/build -DCOMPILING_RTS -DFS_NAMESPACE=rts -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/StgStartup.cmm -o rts/dist/build/StgStartup.o
"inplace/bin/ghc-stage1" -static -H32m -O -Wall -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Iincludes/dist-install/build -Irts -Irts/dist/build -DCOMPILING_RTS -DFS_NAMESPACE=rts -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/StgStdThunks.cmm -o rts/dist/build/StgStdThunks.o
ghc-stage1: panic! (the 'impossible' happened)
(GHC version 9.2.0.20210806:
RegAllocLinear.getFreeRegs: Bad register class
F
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs:51:19 in ghc:GHC.CmmToAsm.Reg.Linear.PPC
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
ghc-stage1: panic! (the 'impossible' happened)
(GHC version 9.2.0.20210806:
RegAllocLinear.getFreeRegs: Bad register class
F
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs:51:19 in ghc:GHC.CmmToAsm.Reg.Linear.PPC
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
ghc-stage1: panic! (the 'impossible' happened)
(GHC version 9.2.0.20210806:
RegAllocLinear.getFreeRegs: Bad register class
F
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs:51:19 in ghc:GHC.CmmToAsm.Reg.Linear.PPC
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
make[1]: *** [rts/ghc.mk:325: rts/dist/build/Exception.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [rts/ghc.mk:325: rts/dist/build/Apply.o] Error 1
make[1]: *** [rts/ghc.mk:325: rts/dist/build/Compact.o] Error 1
ghc-stage1: panic! (the 'impossible' happened)
(GHC version 9.2.0.20210806:
RegAllocLinear.getFreeRegs: Bad register class
F
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs:51:19 in ghc:GHC.CmmToAsm.Reg.Linear.PPC
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
make[1]: *** [rts/ghc.mk:325: rts/dist/build/HeapStackCheck.o] Error 1
ghc-stage1: panic! (the 'impossible' happened)
(GHC version 9.2.0.20210806:
RegAllocLinear.getFreeRegs: Bad register class
F
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs:51:19 in ghc:GHC.CmmToAsm.Reg.Linear.PPC
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
make[1]: *** [rts/ghc.mk:325: rts/dist/build/StgStartup.o] Error 1
ghc-stage1: panic! (the 'impossible' happened)
(GHC version 9.2.0.20210806:
RegAllocLinear.getFreeRegs: Bad register class
F
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs:51:19 in ghc:GHC.CmmToAsm.Reg.Linear.PPC
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
make[1]: *** [rts/ghc.mk:325: rts/dist/build/StgMiscClosures.o] Error 1
ghc-stage1: panic! (the 'impossible' happened)
(GHC version 9.2.0.20210806:
RegAllocLinear.getFreeRegs: Bad register class
F
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs:51:19 in ghc:GHC.CmmToAsm.Reg.Linear.PPC
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
make[1]: *** [rts/ghc.mk:325: rts/dist/build/StgStdThunks.o] Error 1
ghc-stage1: panic! (the 'impossible' happened)
(GHC version 9.2.0.20210806:
RegAllocLinear.getFreeRegs: Bad register class
F
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs:51:19 in ghc:GHC.CmmToAsm.Reg.Linear.PPC
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
make[1]: *** [rts/ghc.mk:325: rts/dist/build/PrimOps.o] Error 1
make: *** [Makefile:128: all] Error 2
```
## Expected behavior
Build to pass like for alpha1 and alpha2.
## Environment
* GHC version used: 8.10.5
Optional:
* Operating System: Fedora Linux
* System Architecture: ppc64le
cc @trommler9.2.1https://gitlab.haskell.org/ghc/ghc/-/issues/19921GHC panic when fiddling with quantified constraints2021-09-28T12:39:16ZAsad SaeeduddinGHC panic when fiddling with quantified constraints## Summary
Given the following code:
```haskell
{-# LANGUAGE
QuantifiedConstraints
, StandaloneKindSignatures
, TypeOperators
, GADTs
, ConstraintKinds
, RankNTypes
, UndecidableInstances
, ImpredicativeTypes
#-}
modu...## Summary
Given the following code:
```haskell
{-# LANGUAGE
QuantifiedConstraints
, StandaloneKindSignatures
, TypeOperators
, GADTs
, ConstraintKinds
, RankNTypes
, UndecidableInstances
, ImpredicativeTypes
#-}
module Typelevel.Constraint.Repro where
import Data.Kind (Constraint, Type)
type Dict :: Constraint -> Type
data Dict c
where
Dict :: c => Dict c
type (⇒) :: Constraint -> Constraint -> Constraint
type c ⇒ d = c => d
infixr 0 ⇒
type (\/) :: Constraint -> Constraint -> Constraint
type a \/ b = (forall r. (a ⇒ r, b ⇒ r) ⇒ r)
infixr 5 \/
dict :: Dict ((x \/ y) \/ z ⇒ x \/ y \/ z)
dict = Dict
```
GHC will blow up with the following error message:
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.10.4:
GHC.StgToCmm.Env: variable not found
irred_a1vk
local binds for:
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1179:37 in ghc:Outputable
pprPanic, called at compiler/GHC/StgToCmm/Env.hs:149:9 in ghc:GHC.StgToCmm.Env
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
## Steps to reproduce
Compiling the module given above with GHC 8.10.4 should do it.
## Expected behavior
GHC should not panic, and should either produce a type error or a successful compilation.
## Environment
* GHC version used: 8.10.49.2.1ZubinZubinhttps://gitlab.haskell.org/ghc/ghc/-/issues/19730GHC 9.2.1-alpha1–only panic (tyConAppTyCon)2021-04-22T21:46:32ZRyan ScottGHC 9.2.1-alpha1–only panic (tyConAppTyCon)The following program compiles with GHC 8.10.4 or 9.0.1:
```hs
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UnboxedTuples #-}
module Bug where
import GHC.Exts
f :: fora...The following program compiles with GHC 8.10.4 or 9.0.1:
```hs
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UnboxedTuples #-}
module Bug where
import GHC.Exts
f :: forall a b. a -> b
f = raise# @a @_ @b
```
But panics when compiled with GHC 9.2.1-alpha1:
```
$ ~/Software/ghc-9.2.1-alpha1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghc: panic! (the 'impossible' happened)
(GHC version 9.2.0.20210331:
tyConAppTyCon
r_aiJ
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Type.hs:1426:52 in ghc:GHC.Core.Type
```9.2.1https://gitlab.haskell.org/ghc/ghc/-/issues/19633Valid unicode characters cause compiler lexing error2021-04-02T17:54:42ZLeo ZhangValid unicode characters cause compiler lexing error## Summary
Here's a perfectly valid Haskell program:
```hs
module Main (main) where
main = putStrLn "🫂"
```
This does not compile. Instead, GHC reports `lexical error in string/character literal at character '\129730'`.
My guess is ...## Summary
Here's a perfectly valid Haskell program:
```hs
module Main (main) where
main = putStrLn "🫂"
```
This does not compile. Instead, GHC reports `lexical error in string/character literal at character '\129730'`.
My guess is that this is a similar problem to https://gitlab.haskell.org/ghc/ghc/-/issues/5518. It looks like this emoji ("people hugging") was added in Unicode 13, released on March 10th, 2020.
I know nothing about how GHC works, but maybe the Unicode tables need to be renewed (taking the terminology from https://gitlab.haskell.org/ghc/ghc/-/issues/5518#note_158430)?
## Environment
* GHC version used: 8.10.4
Optional:
* Operating System: Arch Linux
* System Architecture: x86_649.2.1https://gitlab.haskell.org/ghc/ghc/-/issues/19360panic refineFromInScope from 3b8235334b7838013c9e955db3e7762a1c7fef432022-03-31T02:23:24ZAlan Zimmermanpanic refineFromInScope from 3b8235334b7838013c9e955db3e7762a1c7fef43## Summary
After 3b8235334b7838013c9e955db3e7762a1c7fef43 landed, my TTG `Dump.hs` for API annotations causes a panic on `refineFromInscope`.
I minimised this to a reproduction from
```haskell
{-# LANGUAGE DeriveDataTypeable #-}
{-# L...## Summary
After 3b8235334b7838013c9e955db3e7762a1c7fef43 landed, my TTG `Dump.hs` for API annotations causes a panic on `refineFromInscope`.
I minimised this to a reproduction from
```haskell
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module GHC.Hs.Dump1 where
import qualified GHC.Utils.Ppr as Pretty
import GHC.Prelude (Maybe(..), maybe,Bool (True), ($), head)
import Data.Data (Data,Typeable, gmapQ, cast)
import Data.String
import GHC.Exts (oneShot)
runSDoc :: SDoc -> (Bool -> Pretty.Doc)
runSDoc (SDoc m) = m
{-# COMPLETE SDoc #-}
pattern SDoc :: (Bool -> Pretty.Doc) -> SDoc
pattern SDoc m <- SDoc' m
where
SDoc m = SDoc' (oneShot m)
newtype SDoc = SDoc' (Bool -> Pretty.Doc)
vcat :: [SDoc] -> SDoc
vcat ds = head ds
docToSDoc :: Pretty.Doc -> SDoc
docToSDoc d = SDoc (\_ -> d)
text :: String -> SDoc
text s = docToSDoc $ Pretty.text s
data SrcSpanAnn' a = SrcSpanAnn a
deriving (Data)
data ApiAnn' ann
= ApiAnn ann
deriving (Data)
showAstData :: Data a => Bool -> a -> SDoc
showAstData ba a0 = showAstData' a0
where
showAstData' :: Data a => a -> SDoc
showAstData' =
generic `extQ` srcSpanAnnA
where generic :: Data a => a -> SDoc
generic t = vcat (gmapQ showAstData' t)
srcSpanAnnA :: SrcSpanAnn' (ApiAnn' ()) -> SDoc
srcSpanAnnA = locatedAnn''
locatedAnn'' :: forall a. (Typeable a, Data a)
=> SrcSpanAnn' a -> SDoc
locatedAnn'' ss =
case cast ss of
Just ((SrcSpanAnn ann ) :: SrcSpanAnn' a) ->
case ba of
True
-> showAstData' ann
Nothing -> text "locatedAnn:unmatched"
-- | Extend a generic query by a type-specific case
extQ :: ( Typeable a
, Typeable b
)
=> (a -> q)
-> (b -> q)
-> a
-> q
extQ f g a = maybe (f a) g (cast a)
```
which gives
```
compiler/GHC/Hs/Dump1.hs:62:19: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In a case alternative:
Patterns of type ‘Bool’ not matched: ghc-prim:GHC.Types.False
|
62 | case ba of
| ^^^^^^^^^^...
ghc: panic! (the 'impossible' happened)
(GHC version 9.1.20210130:
refineFromInScope
InScope {wild_00 eta_B0 ba_a1w2 a0_a1w3 $tApiAnn'_a1ya
$cApiAnn_a1yb $tSrcSpanAnn'_a1yc $cSrcSpanAnn_a1yd a_a32a
$dData_a32b $cgfoldl_a3aO $cdataCast1_a3bC $cgmapQl_a3cD
$cgmapQr_a3cW $cgmapQ_a3de $cgmapQi_a3dr $cgmapM_a3dG $cgmapMp_a3e0
$cgmapMo_a3ek $cgfoldl_a3eG $cdataCast1_a3fm $cgmapQl_a3fY
$cgmapQr_a3ga $cgmapQ_a3gm $cgmapQi_a3gw $cgmapM_a3gG $cgmapMp_a3gS
$cgmapMo_a3h4 $krep_a3kK $krep_a3kL $krep_a3kM $krep_a3kN
$krep_a3kO $krep_a3kP $krep_a3kQ $krep_a3kR $krep_a3kS $krep_a3kT
runSDoc vcat docToSDoc text showAstData extQ $tc'SDoc' $tcSDoc
$tc'SrcSpanAnn $tcSrcSpanAnn' $tc'ApiAnn $tcApiAnn' $fDataApiAnn'
$fDataSrcSpanAnn' $mSDoc $bSDoc $trModule $bSDoc_s3NK
docToSDoc_s3NL text_s3NP runSDoc_s3NQ $cApiAnn_s3Ol $cApiAnn_s3Om
$cApiAnn_s3On $tApiAnn'_s3Oo $tApiAnn'_s3Op $tApiAnn'_s3Oq
$cSrcSpanAnn_s3Or $cSrcSpanAnn_s3Os $cSrcSpanAnn_s3Ot
$tSrcSpanAnn'_s3Ou $tSrcSpanAnn'_s3Ov $tSrcSpanAnn'_s3Ow
$trModule_s3Ox $trModule_s3Oy $trModule_s3Oz $trModule_s3OA
$krep_s3OB $tcSDoc_s3OC $tcSDoc_s3OD $tc'SDoc'_s3OE $tc'SDoc'_s3OF
$tcSrcSpanAnn'_s3OG $tcSrcSpanAnn'_s3OH $krep_s3OI
$tc'SrcSpanAnn_s3OJ $tc'SrcSpanAnn_s3OK $cp1Data_s3Pk
$tcApiAnn'_s3R4 $tcApiAnn'_s3R5 $krep_s3R6 $tc'ApiAnn_s3R7
$tc'ApiAnn_s3R8 $cp1Data_s3R9 $cgmapT_s3RT $cgmapT_s3RU
showAstData'_s3RW $dTypeable_s3S2 $dTypeable_s3S3 $dTypeable_s3S6
$dData_s3S7 $dTypeable_s3Sd $dTypeable_s3Se $dTypeable_s3Sh
$s$fDataApiAnn'_s3Sl $s$cgmapMo_s3Ss $s$cgmapT_s3Su $s$cgmapQl_s3Sw
$s$cgmapQ_s3Sy $s$cgmapQr_s3SA $s$cgmapQi_s3SC $s$cgmapM_s3SE
$s$cgmapMp_s3SK $s$cdataCast1_s3SQ $s$cp1Data_s3SS $s$cgfoldl_s3T0
$scast_s3T6 $scast_s3T9 lvl_s3Tg lvl_s3Th lvl_s3Ti lvl_s3Tj
lvl_s3Tk lvl_s3Tl lvl_s3Tm lvl_s3Tn lvl_s3To lvl_s3Tp lvl_s3Tq
lvl_s3Tr lvl_s3Tv lvl_s3Tw lvl_s3Tx lvl_s3Ty lvl_s3Tz lvl_s3TC
lvl_s3TD lvl_s3TG lvl_s3U0 lvl_s3U1 lvl_s3Ul lvl_s3Um lvl_s3Uo
lvl_s3Uq lvl_s3Ur lvl_s3Uu lvl_s3Uv $dTypeable_s3Uz $dTypeable_s3UC
lvl_s3UE lvl_s3UG lvl_s3UH lvl_s3UJ lvl_s3UK lvl_s3UL lvl_s3UM
lvl_s3UN lvl_s3UT $dTypeable_s3UV lvl_s3UX lvl_s3UY lvl_s3V1
lvl_s3V3 lvl_s3Vn lvl_s3Vo lvl_s3Vp lvl_s3Vs lvl_s3Vt lvl_s3Vu
lvl_s3Vx lvl_s3Vz lvl_s3VC lvl_s3VE $dTypeable_s3VF
$sshowAstData'_s3VJ showAstData'_s3VM showAstData_s3VN}
$sshowAstData'_s3Si
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Opt/Simplify/Env.hs:685:30 in ghc:GHC.Core.Opt.Simplify.Env
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
## Steps to reproduce
Build GHC from commit 3b8235334b7838013c9e955db3e7762a1c7fef43
Invoke the stage0 compiler on the Dump1.hs file shown above. My command line (from invoking hadrian with -V, will not be portable) is
```
_build/stage0/bin/ghc -Wall -fdiagnostics-color=never -hisuf p_hi -osuf p_o -hcsuf p_hc -static -prof -eventlog -hide-all-packages -no-user-package-db '-package-env -' '-package-db _build/stage1/lib/package.conf.d' '-this-unit-id ghc-9.1' '-package-id array-0.5.4.0' '-package-id base-4.16.0.0' '-package-id binary-0.8.7.0' '-package-id bytestring-0.10.12.0' '-package-id containers-0.6.4.1' '-package-id deepseq-1.4.4.0' '-package-id directory-1.3.6.1' '-package-id exceptions-0.10.4' '-package-id filepath-1.4.2.1' '-package-id ghc-boot-9.1' '-package-id ghc-heap-9.1' '-package-id ghci-9.1' '-package-id hpc-0.6.1.0' '-package-id parsec-3.1.14.0' '-package-id process-1.6.10.0' '-package-id template-haskell-2.17.0.0' '-package-id terminfo-0.4.1.4' '-package-id time-1.11.1.1' '-package-id transformers-0.5.6.2' '-package-id unix-2.7.2.2' -i -i/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/compiler/build -i/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/compiler/build/autogen -i/home/alanz/mysrc/git.haskell.org/worktree/exactprint/compiler -Iincludes -I_build/stage1/lib -I_build/stage1/compiler/build -I_build/stage1/compiler/build/. -I_build/stage1/compiler/build/../rts/dist/build -Icompiler/. -Icompiler/../rts/dist/build -I/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/x86_64-linux-ghc-9.1.20210212/process-1.6.10.0/include -I/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/x86_64-linux-ghc-9.1.20210212/unix-2.7.2.2/include -I/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/x86_64-linux-ghc-9.1.20210212/time-1.11.1/include -I/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/x86_64-linux-ghc-9.1.20210212/bytestring-0.10.12.0/include -I/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/x86_64-linux-ghc-9.1.20210212/base-4.16.0.0/include -I/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/x86_64-linux-ghc-9.1.20210212/ghc-bignum-1.0/include -I/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/x86_64-linux-ghc-9.1.20210212/rts-1.0/include -I_build/stage1/lib -optc-I_build/stage1/lib -optP-include -optP_build/stage1/compiler/build/autogen/cabal_macros.h -optP-DHAVE_INTERNAL_INTERPRETER -optP-DCAN_LOAD_DLL -outputdir _build/stage1/compiler/build -Wnoncanonical-monad-instances -optc-Wno-error=inline -optP-Wno-nonportable-include-path -c compiler/GHC/Hs/Dump1.hs -o _build/stage1/compiler/build/GHC/Hs/Dump.p_o -O2 -H32m -Wall -Wno-name-shadowing -Wnoncanonical-monad-instances -Wnoncanonical-monoid-instances -this-unit-id ghc -XHaskell2010 -XNoImplicitPrelude -XBangPatterns -XScopedTypeVariables -XMonoLocalBinds -no-global-package-db -package-db=/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/package.conf.d -ghcversion-file=/home/alanz/mysrc/git.haskell.org/worktree/exactprint/_build/stage1/lib/ghcversion.h -Wno-deprecated-flags -Wcpp-undef
```
## Expected behavior
It should compile without a panic
## Environment
* GHC version used: 3b8235334b7838013c9e955db3e7762a1c7fef43
Optional:
* Operating System: Debian testing
* System Architecture: amd64
FYI, my bisect log is
```
$ git bisect log
git bisect start
# bad: [ab5fd982a7a501136cb8b90fa841c02cc9551b5a] Bump Haddock submodule
git bisect bad ab5fd982a7a501136cb8b90fa841c02cc9551b5a
# good: [81f0665513d65c2d7e544cbe8adeff4b0d6fdfff] Separate AST from GhcPass (#18936)
git bisect good 81f0665513d65c2d7e544cbe8adeff4b0d6fdfff
# good: [ae8379abb8aa1defc86dc60bece70546d42af177] Ppr: compute length of string literals at compile time (#19266)
git bisect good ae8379abb8aa1defc86dc60bece70546d42af177
# bad: [6085cfb5e508e969ecb69d8dbeb8cfd1fb87ca3d] Remove misleading 'lazy' pattern matches from 'head' and 'tail' in Data.List.NonEmpty
git bisect bad 6085cfb5e508e969ecb69d8dbeb8cfd1fb87ca3d
# bad: [a3d995fa18079ac31623febc8f41297c9acfb6a5] Fix -dynamic-too with wired-in modules (#19264)
git bisect bad a3d995fa18079ac31623febc8f41297c9acfb6a5
# bad: [f5d62eb2d5a1058f355aaa1fd0a959694d160ec4] ghci: Take editor from VISUAL environment variable
git bisect bad f5d62eb2d5a1058f355aaa1fd0a959694d160ec4
# bad: [3b8235334b7838013c9e955db3e7762a1c7fef43] Make PatSyn immutable
git bisect bad 3b8235334b7838013c9e955db3e7762a1c7fef43
# good: [5140841ca1acaeaeef893233ae3d08ce4573b01b] Fix check-uniques script
git bisect good 5140841ca1acaeaeef893233ae3d08ce4573b01b
# first bad commit: [3b8235334b7838013c9e955db3e7762a1c7fef43] Make PatSyn immutable
```9.2.1https://gitlab.haskell.org/ghc/ghc/-/issues/19264hgmp-0.1.2 panics on HEAD (lookupGlobal) due to mismatched GHC/Num/BigNat.hi2021-02-01T13:53:00ZRyan Scotthgmp-0.1.2 panics on HEAD (lookupGlobal) due to mismatched GHC/Num/BigNat.hi_Originally observed on a `head.hackage` CI build [here](https://gitlab.haskell.org/ghc/head.hackage/-/jobs/563516#L6940)._
Attempting to build the `hgmp-0.1.2` package with GHC HEAD (at commit b18d9e97252c9dd12f08d3e6f56bfec6a6d2469a) ..._Originally observed on a `head.hackage` CI build [here](https://gitlab.haskell.org/ghc/head.hackage/-/jobs/563516#L6940)._
Attempting to build the `hgmp-0.1.2` package with GHC HEAD (at commit b18d9e97252c9dd12f08d3e6f56bfec6a6d2469a) triggers a panic. To reproduce, do the following:
```
$ cabal repl -b hgmp -w ~/Software/ghc-9.1.20210124/bin/ghc --constraint="hgmp==0.1.2" --allow-newer=base,ghc-prim
Resolving dependencies...
Build profile: -w ghc-9.1.20210124 -O1
In order, the following will be built (use -v for more details):
- hgmp-0.1.2 (lib) (requires build)
- fake-package-0 (lib) (first run)
Starting hgmp-0.1.2 (lib)
Building hgmp-0.1.2 (lib)
Failed to build hgmp-0.1.2.
Build log (
/home/ryanglscott/.cabal/logs/ghc-9.1.20210124/hgmp-0.1.2-40e5acddb0bd81ddbcf00e2606c0cf5908c10258cb69ed9e9609bda285e2d340.log
):
Configuring library for hgmp-0.1.2..
Preprocessing library for hgmp-0.1.2..
Building library for hgmp-0.1.2..
[1 of 4] Compiling Numeric.GMP.Types ( dist/build/Numeric/GMP/Types.hs, dist/build/Numeric/GMP/Types.o, dist/build/Numeric/GMP/Types.dyn_o )
src/Numeric/GMP/Types.hsc:14:1: warning: [-Wunused-imports]
The import of ‘Data.Typeable’ is redundant
except perhaps to import instances from ‘Data.Typeable’
To import instances alone, use: import Data.Typeable()
|
14 | import Data.Typeable
| ^^^^^^^^^^^^^^^^^^^^
src/Numeric/GMP/Types.hsc:20:36: warning: [-Wunused-imports]
The import of ‘nullPtr’ from module ‘Foreign’ is redundant
|
20 | import Foreign (Storable(..), Ptr, nullPtr, plusPtr)
| ^^^^^^^
ghc: panic! (the 'impossible' happened)
(GHC version 9.1.20210124:
lookupGlobal
Bad interface file: /home/ryanglscott/Software/ghc-9.1.20210124/lib/../lib/x86_64-linux-ghc-9.1.20210124/ghc-bignum-1.0/GHC/Num/BigNat.hi
mismatched interface file profile tag (wanted "dyn", got "")
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Tc/Utils/Env.hs:155:32 in ghc:GHC.Tc.Utils.Env
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
cabal: Failed to build hgmp-0.1.2 (which is required by fake-package-0). See
the build log above for details.
```
This is a regression from GHC 9.0 and earlier. I haven't quite figured out how to minimize the example yet, unfortunately.
This appears to be `ghc-bignum`–related, so perhaps @hsyl20 might know what is happening here?9.2.1https://gitlab.haskell.org/ghc/ghc/-/issues/19180T14720 fails with Core Lint failure in DEBUG compiler2021-01-11T08:44:11ZBen GamariT14720 fails with Core Lint failure in DEBUG compilerFound while looking at !2890:
```
Compile failed (exit code 1) errors were:
*** Core Lint errors : in result of Worker Wrapper binds *** ...Found while looking at !2890:
```
Compile failed (exit code 1) errors were:
*** Core Lint errors : in result of Worker Wrapper binds ***
T14270.hs:86:1: warning:
Non-top-level binder has an external name: typeRepKind
In the RHS of typeRepKind :: forall k (a :: k).
TypeRep a -> TypeRep k
Substitution: [TCvSubst
In scope: InScope {}
Type env: []
Co env: []]
```9.2.1Sebastian GrafSebastian Grafhttps://gitlab.haskell.org/ghc/ghc/-/issues/19140panic: No skolem info when trying to use variable with polymorphic kind as Ty...2020-12-31T13:44:07ZJakob Brünkerpanic: No skolem info when trying to use variable with polymorphic kind as Type/Constraint## Summary
In a quantified constraint in the context for an instance declaration, when trying to use a type variable with a polymorphic kind as either a `Type` or a `Constraint`, ghc will panic.
## Steps to reproduce
Each of the follo...## Summary
In a quantified constraint in the context for an instance declaration, when trying to use a type variable with a polymorphic kind as either a `Type` or a `Constraint`, ghc will panic.
## Steps to reproduce
Each of the following three instances trigger the error
```haskell
{-# LANGUAGE ExplicitForAll , PolyKinds #-}
instance (forall (a :: k) . a) => Show b
instance (forall (a :: k) . Show a) => Show b
instance (forall (a :: k) . a -> a) => Show b
```
Error:
```
ghc: panic! (the 'impossible' happened)
(GHC version 9.0.0.20201227:
No skolem info:
[k_aEZ[sk:1]]
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Outputable.hs:1230:37 in ghc:GHC.Utils.Outputable
pprPanic, called at compiler/GHC/Tc/Errors.hs:2810:17 in ghc:GHC.Tc.Errors
```
## Expected behavior
8.10 has the expected behavior: show the following type error
```
Bug.hs:3:29: error:
• Expected a constraint, but ‘a’ has kind ‘k’
• In the instance declaration for ‘Show b’
|
3 | instance (forall (a :: k) . a) => Show b
| ^
Bug.hs:4:34: error:
• Expected a type, but ‘a’ has kind ‘k’
• In the first argument of ‘Show’, namely ‘a’
In the instance declaration for ‘Show b’
|
4 | instance (forall (a :: k) . Show a) => Show b
| ^
Bug.hs:5:29: error:
• Expected a constraint, but ‘a -> a’ has kind ‘*’
• In the instance declaration for ‘Show b’
|
5 | instance (forall (a :: k) . a -> a) => Show b
| ^^^^^^
Failed, no modules loaded.
```
## Environment
* GHC version used: 9.0.0.20201227
Optional:
* Operating System: Ubuntu inside WSL2 inside Windows 10
* System Architecture: x86_649.2.1https://gitlab.haskell.org/ghc/ghc/-/issues/18326"lookupIdSubst" warnings when compiling haddock2021-08-15T21:06:57ZSebastian Graf"lookupIdSubst" warnings when compiling haddockI'm getting warnings of the form
```
| Run Ghc CompileHs Stage1: utils/haddock/haddock-api/src/Haddock/Types.hs => _build/stage1/utils/haddock/build/Haddock/Types.o
...
WARNING: file compiler/GHC/Core/Subst.hs, line 256
GHC.Core.Subs...I'm getting warnings of the form
```
| Run Ghc CompileHs Stage1: utils/haddock/haddock-api/src/Haddock/Types.hs => _build/stage1/utils/haddock/build/Haddock/Types.o
...
WARNING: file compiler/GHC/Core/Subst.hs, line 256
GHC.Core.Subst.lookupIdSubst exprIsConApp1
subst_expr $cp1Exception_skvd
InScope {r_ahOg a_ahOh w1_ahOk $fExceptionHaddockException}
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Outputable.hs:1282:29 in ghc:GHC.Utils.Outputable
warnPprTrace, called at compiler/GHC/Core/Subst.hs:255:18 in ghc:GHC.Core.Subst
...
```
Might not lead to miscompilations, but we should look into where we construct the invalid in-scope set. Judging from the size of the reported in-scope set, this should be relatively easy to pin down once reproduced locally.9.2.1https://gitlab.haskell.org/ghc/ghc/-/issues/16745A combination of DuplicateRecordFields and import hiding triggers a GHC panic2022-09-13T14:28:41ZdredozubovA combination of DuplicateRecordFields and import hiding triggers a GHC panic# Summary
GHC panics with:
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.3 for x86_64-apple-darwin):
filterImports/combine
(field, field, Nothing)
($sel:field:R, R{R, R; field}, Nothing)
Call stack:
CallSt...# Summary
GHC panics with:
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.3 for x86_64-apple-darwin):
filterImports/combine
(field, field, Nothing)
($sel:field:R, R{R, R; field}, Nothing)
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/rename/RnNames.hs:901:23 in ghc:RnNames
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
# Steps to reproduce
`A.hs`:
```
module Main where
import B hiding (field)
main = print "ok"
```
`B.hs`:
```
{-# LANGUAGE DuplicateRecordFields #-}
module B
( R(..)
, module C
) where
import C
data R = R { field :: Int}
```
`C.hs`:
```
module C where
field = (++ "foo")
```
# Expected behavior
compile time error instead of ghc panic
# Environment
* GHC version used: 8.6.3
Optional:
* Operating System: OS X Sierra
* System Architecture: x86_649.2.1Adam GundryAdam Gundryhttps://gitlab.haskell.org/ghc/ghc/-/issues/14873The well-kinded type invariant (in TcType)2021-09-07T15:47:33ZRyan ScottThe well-kinded type invariant (in TcType)(Originally noticed [here](https://travis-ci.org/goldfirere/singletons/jobs/347945148#L1179).)
The following program typechecks on GHC 8.2.2 on GHC 8.4.1, but panics on GHC HEAD:
```hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTyp...(Originally noticed [here](https://travis-ci.org/goldfirere/singletons/jobs/347945148#L1179).)
The following program typechecks on GHC 8.2.2 on GHC 8.4.1, but panics on GHC HEAD:
```hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
module Bug where
import Data.Kind (Type)
data family Sing (a :: k)
newtype instance Sing (f :: k1 ~> k2) =
SLambda { applySing :: forall t. Sing t -> Sing (Apply f t) }
data TyFun :: Type -> Type -> Type
type a ~> b = TyFun a b -> Type
infixr 0 ~>
type family Apply (f :: k1 ~> k2) (x :: k1) :: k2
class SingI (a :: k) where
sing :: Sing a
data ColSym1 :: f a -> a ~> Bool
type instance Apply (ColSym1 x) y = Col x y
class PColumn (f :: Type -> Type) where
type Col (x :: f a) (y :: a) :: Bool
class SColumn (f :: Type -> Type) where
sCol :: forall (x :: f a) (y :: a).
Sing x -> Sing y -> Sing (Col x y :: Bool)
instance (SColumn f, SingI x) => SingI (ColSym1 (x :: f a) :: a ~> Bool) where
sing = SLambda (sCol (sing @_ @x))
```
```
$ /opt/ghc/head/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.5.20180201 for x86_64-unknown-linux):
piResultTy
k_aZU[tau:1]
(a_aW8[sk:1] |> <*>_N)
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
```
<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 regression (piResultTy)","status":"New","operating_system":"","component":"Compiler (Type checker)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"(Originally noticed [https://travis-ci.org/goldfirere/singletons/jobs/347945148#L1179 here].)\r\n\r\nThe following program typechecks on GHC 8.2.2 on GHC 8.4.1, but panics on GHC HEAD:\r\n\r\n{{{#!hs\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 (Type)\r\n\r\ndata family Sing (a :: k)\r\n\r\nnewtype instance Sing (f :: k1 ~> k2) =\r\n SLambda { applySing :: forall t. Sing t -> Sing (Apply f t) }\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\nclass SingI (a :: k) where\r\n sing :: Sing a\r\n\r\ndata ColSym1 :: f a -> a ~> Bool\r\ntype instance Apply (ColSym1 x) y = Col x y\r\n\r\nclass PColumn (f :: Type -> Type) where\r\n type Col (x :: f a) (y :: a) :: Bool\r\n\r\nclass SColumn (f :: Type -> Type) where\r\n sCol :: forall (x :: f a) (y :: a).\r\n Sing x -> Sing y -> Sing (Col x y :: Bool)\r\n\r\ninstance (SColumn f, SingI x) => SingI (ColSym1 (x :: f a) :: a ~> Bool) where\r\n sing = SLambda (sCol (sing @_ @x))\r\n}}}\r\n\r\n{{{\r\n$ /opt/ghc/head/bin/ghc Bug.hs\r\n[1 of 1] Compiling Bug ( Bug.hs, Bug.o )\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.5.20180201 for x86_64-unknown-linux):\r\n piResultTy\r\n k_aZU[tau:1]\r\n (a_aW8[sk:1] |> <*>_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}}}","type_of_failure":"OtherFailure","blocking":[]} -->9.2.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.dev