GHC 8.2.1 regression when combining GND with TypeError (solveDerivEqns: probable loop)
This code panics on GHC 8.2.1 and later:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
module Bug where
import GHC.TypeLits
newtype Baz = Baz Foo
deriving Bar
newtype Foo = Foo Int
class Bar a where
bar :: a
instance (TypeError (Text "Boo")) => Bar Foo where
bar = undefined
$ /opt/ghc/8.2.1/bin/ghci Bug.hs
GHCi, version 8.2.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
ghc: panic! (the 'impossible' happened)
(GHC version 8.2.1 for x86_64-unknown-linux):
solveDerivEqns: probable loop
DerivSpec
ds_loc = Bug.hs:9:12-14
ds_name = $fBarBaz
ds_tvs = []
ds_cls = Bar
ds_tys = [Baz]
ds_theta = [ThetaOrigin
to_tvs = []
to_givens = []
to_wanted_origins = [Bar Foo, (Foo :: *) ~R# (Baz :: *)]]
ds_mechanism = newtype
[[s0_a1D7[fuv:0]]]
Call stack:
CallStack (from HasCallStack):
prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable
callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable
pprPanic, called at compiler/typecheck/TcDerivInfer.hs:515:9 in ghc:TcDerivInfer
This is a regression since GHC 8.0.2, in which it does compile successfully.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | high |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |