[GHC] #14326: Panic on COMPLETE pragma with mismatched type variable order

#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 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: -------------------------------------+------------------------------------- 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 #-} }}} 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 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14326 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): I feel like you're leaving out some important information here. I tried loading this file (I had to add some language extensions that you left out): {{{#!hs {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ScopedTypeVariables #-} module Bug where 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 #-} }}} I compiled this with 8.2.1, but it did not panic. What am I missing? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14326#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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 #-} }}}
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
}}}
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 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:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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

#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: | -------------------------------------+------------------------------------- Comment (by dailectic): Replying to [comment:1 RyanGlScott]:
I feel like you're leaving out some important information here. I tried loading this file (I had to add some language extensions that you left out):
{{{#!hs {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ScopedTypeVariables #-} module Bug where
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 #-} }}}
I compiled this with 8.2.1, but it did not panic. What am I missing?
Thanks, I was mistaken and the source seems to be in interaction with nested pattern matches rather than just the declaration. I've edited the ticket to reflect this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14326#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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: | PatternSynonyms 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: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * keywords: => PatternSynonyms Comment: Thanks for the update. Interestingly, this does //not// panic on GHC HEAD, which in some ways makes this like an inverse of #14135 (which panics with a `mkOneConFull` error on HEAD, but not 8.2.1). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14326#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14326: Panic on COMPLETE pragma with mismatched type variable order -------------------------------------+------------------------------------- Reporter: dailectic | Owner: RyanGlScott Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: | PatternSynonyms 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: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * owner: (none) => RyanGlScott Comment: Sure enough, the commit that fixed this bug (but also introduced the bug in #14135) was 6b77914cd37b697354611bcd87897885c1e5b4a6 (`Fix instantiation of pattern synonyms`). I'll add a regression test. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14326#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14326: Panic on COMPLETE pragma with mismatched type variable order
-------------------------------------+-------------------------------------
Reporter: dailectic | Owner: RyanGlScott
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.1
Resolution: | Keywords:
| PatternSynonyms
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: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott

#14326: Panic on COMPLETE pragma with mismatched type variable order -------------------------------------+------------------------------------- Reporter: dailectic | Owner: RyanGlScott Type: bug | Status: closed Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.2.1 Resolution: fixed | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: x86_64 | (amd64) Type of failure: Compile-time | Test Case: crash or panic | patsyn/should_compile/T14326 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * testcase: => patsyn/should_compile/T14326 * resolution: => fixed * milestone: => 8.4.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14326#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC