
#14326: Panic on COMPLETE pragma with mismatched type variable order -------------------------------------+------------------------------------- Reporter: dailectic | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by dailectic: Old description:
The motivating example is to allow patterns with phantom types to interact nicely with TypeApplications, so in the below we can do `L @Int :: a -> L a Int` to specify the phantom. {{{#!hs data E a b = L' a | R b pattern L :: forall b a. a -> E a b pattern L a = L' a {-# COMPLETE L, R #-} }}}
Issues occur when nesting cases
{{{ {-# OPTIONS_GHC -fwarn-incomplete-patterns #-} testMono :: E (E Int Int) Int -> Int testMono x = case x of L (L _) -> 0 L (R _) -> 1 R _ -> 2 }}}
And GHC panics when polymorphic
{{{ {-# OPTIONS_GHC -fwarn-incomplete-patterns #-} testPoly :: E (E a b) c -> Int testPoly x = case x of L (L _) -> 0 L (R _) -> 1 R _ -> 2 }}}
The compiler balks
{{{ ghc: panic! (the 'impossible' happened) (GHC version 8.2.1 for x86_64-unknown-linux): mkOneConFull: Not TyConApp: c_a50V Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/deSugar/Check.hs:976:30 in ghc:Check
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
}}}
So it seems like there's two related issues here: 1. The COMPLETE pragma does not work in nesting for out-of-order type variables 2. Some printing logic is missing for the error in this polymorphic case
Note that if we define
{{{ pattern L :: forall a b. a -> E a b pattern L a = L' a }}}
Note that we do not get the incomplete warning or the panic, so it seems directly related to the order of the variables, rather than explicit quantification in general
New description: The motivating example is to allow patterns with phantom types to interact nicely with TypeApplications, so in the below we can do `L @Int :: a -> L a Int` to specify the phantom. {{{#!hs {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ExplicitForAll #-} data E a b = L' a | R b pattern L :: forall b a. a -> E a b pattern L a = L' a {-# COMPLETE L, R #-} }}} Issues occur when nesting cases {{{ {-# OPTIONS_GHC -fwarn-incomplete-patterns #-} testMono :: E (E Int Int) Int -> Int testMono x = case x of L (L _) -> 0 L (R _) -> 1 R _ -> 2 }}} And GHC panics when polymorphic {{{ {-# OPTIONS_GHC -fwarn-incomplete-patterns #-} testPoly :: E (E a b) c -> Int testPoly x = case x of L (L _) -> 0 L (R _) -> 1 R _ -> 2 }}} The compiler balks {{{ ghc: panic! (the 'impossible' happened) (GHC version 8.2.1 for x86_64-unknown-linux): mkOneConFull: Not TyConApp: c_a50V Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/deSugar/Check.hs:976:30 in ghc:Check Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} So it seems like there's two related issues here: 1. The COMPLETE pragma does not work in nesting for out-of-order type variables 2. Some printing logic is missing for the error in this polymorphic case Note that if we define {{{ pattern L :: forall a b. a -> E a b pattern L a = L' a }}} Note that we do not get the incomplete warning or the panic, so it seems directly related to the order of the variables, rather than explicit quantification in general -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14326#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler