panic when checking roles off ill-kinded data type.
Issue found while working on !9628 (merged)
If I modify an existing test T15743d
to have an explicit type role annotations
{-# LANGUAGE PolyKinds, DataKinds, ExplicitForAll #-}
{-# LANGUAGE RoleAnnotations #-}
module T15743 where
import Data.Kind
import Data.Proxy
data SimilarKind :: forall (c :: k) (d :: k). Proxy c -> Proxy d -> Type
data T2 k (c :: k) (a :: Proxy c) (b :: Proxy d) (x :: SimilarKind a b)
type role T2 nominal nominal nominal nominal
GHC will panic.
The ./hadrian/build ... test --only=T15743d
fails with
Actual stderr output differs from expected:
--- "/tmp/ghctest-u716vd18/test spaces/testsuite/tests/dependent/should_fail/T15743d.run/T15743d.stderr.normalised" 2023-04-11 20:06:13.352475259 +0300
+++ "/tmp/ghctest-u716vd18/test spaces/testsuite/tests/dependent/should_fail/T15743d.run/T15743d.comp.stderr.normalised" 2023-04-11 20:06:13.352475259 +0300
@@ -1,15 +1,15 @@
+ghc: panic! (the 'impossible' happened)
+ GHC version 9.7.20230411:
+ updateRole
+ T2
+ k_aiU[sk:1]
+ []
+ Call stack:
+ CallStack (from HasCallStack):
+ callStackDoc, called at compiler/GHC/Utils/Panic.hs:<line>:<column> in <package-id>:GHC.Utils.Panic
+ pprPanic, called at compiler/GHC/Tc/TyCl/Utils.hs:<line>:<column> in <package-id>:GHC.Tc.TyCl.Utils
+ CallStack (from HasCallStack):
+ panic, called at compiler/GHC/Utils/Error.hs:<line>:<column> in <package-id>:GHC.Utils.Error
-T15743d.hs:10:1:
- The kind of ‘T2’ is ill-scoped
- Inferred kind: T2 :: forall (d :: k).
- forall k (c :: k) (a :: Proxy c) (b :: Proxy d) ->
- SimilarKind a b -> *
- NB: Specified variables (namely: (d :: k)) always come first
- Perhaps try this order instead:
- k
- (d :: k)
- (c :: k)
- (a :: Proxy c)
- (b :: Proxy d)
- (x :: SimilarKind a b)
- In the data type declaration for ‘T2’
+
+Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
*** unexpected failure for T15743d(normal)
Performance Metrics (test environment: local):
None collected.
Unexpected results from:
TEST="T15743d"