[GHC] #12144: GHC panic when using DeriveAnyClass with functor-like class and datatype with a type variable in a contravariant position

#12144: GHC panic when using DeriveAnyClass with functor-like class and datatype with a type variable in a contravariant position -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Keywords: Generics | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time Unknown/Multiple | crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The following code {{{#!hs {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE KindSignatures #-} module Example where class C (a :: * -> *) data T a = MkT (a -> Int) deriving C }}} fails to compile with the following GHC panic: {{{ $ /opt/ghc/8.0.1/bin/ghc Example.hs [1 of 1] Compiling Example ( Example.hs, Example.o ) ghc: panic! (the 'impossible' happened) (GHC version 8.0.1 for x86_64-unknown-linux): contravariant Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} The culprit is that when `DeriveAnyClass` comes up with the constraints for typeclass instances whose argument is of kind `* -> *`, it calls [http://git.haskell.org/ghc.git/blob/0676e68cf5fe8696f1f760fef0f35dba14db1104... deepSubtypesContaining], which immediately bails out when it sees a type variable in a contravariant or "bad" position. I'm less sure of what the fix should be. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12144 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12144: GHC panic when using DeriveAnyClass with functor-like class and datatype with a type variable in a contravariant position -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Generics Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: #5462, #7346 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * related: => #5462, #7346 Comment: Mailing list discussion: https://mail.haskell.org/pipermail/ghc- devs/2016-June/012252.html -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12144#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12144: GHC panic when using DeriveAnyClass with functor-like class and datatype with a type variable in a contravariant position -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Generics Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: #5462, #7346, | Differential Rev(s): #12423 | Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * related: #5462, #7346 => #5462, #7346, #12423 Comment: See also #12423, which throws a very similar panic (but for a slightly more sensible reason). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12144#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12144: GHC panic when using DeriveAnyClass with functor-like class and datatype with a type variable in a contravariant position -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Generics Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: #5462, #7346, | Differential Rev(s): Phab:D2961 #12423 | Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D2961 Comment: A WIP attempt at fixing this is at Phab:D2961. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12144#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12144: GHC panic when using DeriveAnyClass with functor-like class and datatype
with a type variable in a contravariant position
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner:
Type: bug | Status: patch
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version: 8.0.1
Resolution: | Keywords: Generics
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash | Test Case:
Blocked By: | Blocking:
Related Tickets: #5462, #7346, | Differential Rev(s): Phab:D2961
#12423 |
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott

#12144: GHC panic when using DeriveAnyClass with functor-like class and datatype with a type variable in a contravariant position -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: Generics Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | tests/deriving/should_compile/T12144_1, | tests/deriving/should_compile/T12144_2 Blocked By: | Blocking: Related Tickets: #5462, #7346, | Differential Rev(s): Phab:D2961 #12423 | Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: patch => closed * testcase: => tests/deriving/should_compile/T12144_1, tests/deriving/should_compile/T12144_2 * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12144#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC