panic lookup_final_id with -fdefer-type-errors and kind error in instance definition
Summary
This file
{-# OPTIONS_GHC -fdefer-type-errors #-}
{-# LANGUAGE ExplicitForAll
, TypeApplications
, KindSignatures
, FlexibleInstances
#-}
foo :: forall (f :: * -> *) . String
foo = ""
instance Show a where
show _ = foo @Int
produces the following error:
Bug.hs:12:17: warning: [-Wdeferred-type-errors]
• Expected kind ‘* -> *’, but ‘Int’ has kind ‘*’
• In the type ‘Int’
In the expression: foo @Int
In an equation for ‘show’: show _ = foo @Int
|
12 | show _ = foo @Int
| ^^^
ghc: panic! (the 'impossible' happened)
(GHC version 9.0.0.20201227:
lookup_final_id
$fShowa
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/Tidy.hs:200:12 in ghc:GHC.Iface.Tidy
Without -fdefer-type-errors
, only the kind error would be shown, not the panic.
Expected behavior
GHC shouldn't panic
Environment
- GHC version used: 9.0.0.20201227 as well as 8.10.2
Optional:
- Operating System: Ubuntu inside WSL2 inside Windows 10
- System Architecture: x86_64