checkImplicationInvariants failure when building servant-server-0.19.2 with HEAD
When building the servant-server-0.19.2
Hackage library using HEAD (at commit a8ed36f9) built with assertions enabled, GHC triggers an assertion error. Here is a minimized example:
{-# LANGUAGE Haskell2010 #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where
import Data.Proxy (Proxy)
data Delayed (env :: *) (c :: *)
data Handler (a :: *)
data Router (a :: *)
class HasServer api where
type ServerT api (m :: * -> *) :: *
route ::
Proxy api
-> Delayed env (Server api)
-> Router env
hoistServerWithContext
:: Proxy api
-> (forall x. m x -> n x)
-> ServerT api m
-> ServerT api n
type Server api = ServerT api Handler
This compiles without issue on GHC 9.4 and earlier:
$ ghc-9.4 Bug.hs -fforce-recomp
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
On HEAD, however:
$ $USERPROFILE/Software/ghc-9.5.20221027/bin/ghc Bug.hs -fforce-recomp
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.5.20221027:
ASSERT failed!
checkImplicationInvariants failure
k_axf[sk:1] has skol info the type synonym declaration for `Server'
ic_info the class declaration for `HasServer'
Implic {
TcLevel = 1
Skolems = k_axf[sk:1] (api_ais[sk:1] :: k_axf[sk:1])
Given-eqs = NoGivenEqs
Status = Unsolved
Given =
Wanted =
WC {wc_impl =
Implic {
TcLevel = 2
Skolems =
Given-eqs = NoGivenEqs
Status = Solved {Dead givens = []}
Given =
Wanted = WC {}
Binds = CoEvBindsVar<aAd>
the type signature for `hoistServerWithContext' }}
Binds = CoEvBindsVar<aAf>
the class declaration for `HasServer' }
Call stack:
CallStack (from HasCallStack):
massertPpr, called at compiler\GHC\Tc\Types\Constraint.hs:1652:17 in ghc:GHC.Tc.Types.Constraint
check_implic, called at compiler\GHC\Tc\Types\Constraint.hs:1646:53 in ghc:GHC.Tc.Types.Constraint
checkImplicationInvariants, called at compiler\GHC\Tc\Utils\Unify.hs:1594:10 in ghc:GHC.Tc.Utils.Unify
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug