Opened 3 weeks ago

Last modified 3 weeks ago

#14174 new bug

GHC panic with TypeInType and type family

Reported by: dfeuer Owned by:
Priority: normal Milestone: 8.2.2
Component: Compiler (Type checker) Version: 8.2.1
Keywords: TypeInType Cc: goldfire, Iceland_jack
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash or panic Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

This rather simple type family,

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

module GenWhoops where
import GHC.Generics

type family GenComp k (x :: k) (y :: k) :: Ordering where
  GenComp ((x :+: y) p) ('L1 x) ('L1 y) = GenComp (x p) x y

produces the following panic:

ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 8.3.20170828 for x86_64-unknown-linux):
        piResultTy
  k_a1LK[tau:1]
  p_a1Lz[sk:1]
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1138:37 in ghc:Outputable
        pprPanic, called at compiler/types/Type.hs:949:35 in ghc:Type

This happens with both GHC 8.2.1 and something very close to HEAD.

Change History (3)

comment:1 Changed 3 weeks ago by dfeuer

This really should just be an error, I imagine. It's an (accidental) non-linear pattern where the two types have different kinds.

comment:2 Changed 3 weeks ago by Iceland_jack

Cc: Iceland_jack added

comment:3 Changed 3 weeks ago by simonpj

Here is a simpler way to trigger the same panic

{-# LANGUAGE  TypeInType, RankNTypes, KindSignatures, PolyKinds #-}
module Foo where

data T k (x :: k) = MkT

data S x = MkS (T (x Int) x)
Note: See TracTickets for help on using tickets.