Opened 2 years ago

Closed 2 years ago

#14520 closed bug (fixed)

GHC panic (TypeInType)

Reported by: Iceland_jack Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.2.1
Keywords: TypeInType Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: polykinds/T14520.hs
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


{-# Language TypeInType, TypeFamilies, TypeOperators #-}

import Data.Kind

type a ~>> b = (a, b) -> Type

data family Sing (a::k)

type family
  (·) (f::a~>>b) (x::a)::b

class PCategory kat where
  type Id  ::kat·a·a
  type Comp::kat·b·c -> kat·a·b -> kat·a·c

class SCategory kat where
  sId   :: Sing a -> Sing (Id::kat a a)
  sComp :: Sing f -> Sing g -> Sing (Comp f g)

triggers a panic

$ ghci -ignore-dot-ghci Bug.hs
GHCi, version 8.3.20171122:  :? for help
[1 of 1] Compiling Main             ( Bug.hs, interpreted )
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 8.3.20171122 for x86_64-unknown-linux):
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1147:37 in ghc:Outputable
        pprPanic, called at compiler/types/Type.hs:951:35 in ghc:Type
        piResultTy, called at compiler/types/Type.hs:2309:34 in ghc:Type
        typeKind, called at compiler/types/Type.hs:2309:46 in ghc:Type
        typeKind, called at compiler/typecheck/TcType.hs:1706:11 in ghc:TcType

Please report this as a GHC bug:

Change History (2)

comment:1 Changed 2 years ago by Simon Peyton Jones <simonpj@…>

In 8b36ed1/ghc:

Build only well-kinded types in type checker

During type inference, we maintain the invariant that every type is
well-kinded /without/ zonking; and in particular that typeKind does
not fail (as it can for ill-kinded types).

But TcHsType.tcInferApps was not guaranteeing this invariant,
resulting in Trac #14174 and #14520.

This patch fixes it, making things better -- but it does /not/
fix the program in Trac #14174 comment:5, which still crashes.
So more work to be done.

See Note [Ensure well-kinded types] in TcHsType

comment:2 Changed 2 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: polykinds/T14520.hs
Note: See TracTickets for help on using tickets.