[GHC] #12083: ghc-8.0.1-rc4: tyConRoles sees a TcTyCon

#12083: ghc-8.0.1-rc4: tyConRoles sees a TcTyCon -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1-rc4 (Type checker) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time Unknown/Multiple | crash Test Case: Yes. | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- {{{#!hs {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UnicodeSyntax #-} import Prelude.Unicode type Constrd a = Num a ⇒ a data ADT a = ADT (Constrd a) ExistentiallyLost data ExistentiallyLost = ∀ u. TC u ⇒ ExistentiallyLost u class u ~ (ATF1 u, ATF2 u) ⇒ TC u where type ATF1 u ∷ * type ATF2 u ∷ * uie_handlers ∷ ADT Int -- Loop: -- - ADT depends on ExistentiallyLost (also the Constrd appendage) -- - ExistentiallyLost depends on TC -- - TC depends on ADT }}} --> {{{ [1 of 1] Compiling Main ( /home/deepfire/src/ghc-testcases /tyconroles-sees-a-tctycon-tyalias.hs, interpreted ) <- ghc: panic! (the 'impossible' happened) (GHC version 8.0.0.20160421 for x86_64-unknown-linux): tyConRoles sees a TcTyCon Constrd Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12083 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12083: ghc-8.0.1-rc4: tyConRoles sees a TcTyCon -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1-rc4 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Yes. Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by _deepfire): * Attachment "tyconroles-sees-a-tctycon-tyalias.hs" added. Test case. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12083 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12083: ghc-8.0.1-rc4: tyConRoles sees a TcTyCon -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1-rc4 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Yes. Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by thomie): @_deepfire: Could you please change your testcase to not depend on `base- unicode-symbols`? That would make it easier to include it in the testsuite later. Thanks. Note to others: you can uncomment `import Prelude.Unicode` and still reproduce the bug. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12083#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12083: ghc-8.0.1-rc4: tyConRoles sees a TcTyCon -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1-rc4 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Yes. Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by _deepfire): * Attachment "tyconroles-sees-a-tctycon-tyalias.hs" added. a testcase not depending on base-unicode-symbols -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12083 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12083: ghc-8.0.1-rc4: tyConRoles sees a TcTyCon -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1-rc4 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Yes. Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by _deepfire): @thomie, done! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12083#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12083: ghc-8.0.1-rc4: tyConRoles sees a TcTyCon -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1-rc4 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Yes. Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by _deepfire: @@ -4,2 +4,0 @@ - - import Prelude.Unicode New description: {{{#!hs {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UnicodeSyntax #-} type Constrd a = Num a ⇒ a data ADT a = ADT (Constrd a) ExistentiallyLost data ExistentiallyLost = ∀ u. TC u ⇒ ExistentiallyLost u class u ~ (ATF1 u, ATF2 u) ⇒ TC u where type ATF1 u ∷ * type ATF2 u ∷ * uie_handlers ∷ ADT Int -- Loop: -- - ADT depends on ExistentiallyLost (also the Constrd appendage) -- - ExistentiallyLost depends on TC -- - TC depends on ADT }}} --> {{{ [1 of 1] Compiling Main ( /home/deepfire/src/ghc-testcases /tyconroles-sees-a-tctycon-tyalias.hs, interpreted ) <- ghc: panic! (the 'impossible' happened) (GHC version 8.0.0.20160421 for x86_64-unknown-linux): tyConRoles sees a TcTyCon Constrd Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12083#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12083: ghc-8.0.1-rc4: tyConRoles sees a TcTyCon -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1-rc4 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Yes. Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Urgh. I know what is going on here. The problem is that `Constrd` is bogus because its right-hand side is constrained and we haven't enabled the right extensions. The validity check fails. Regardless, GHC tries to continue to check the remaining declarations. To do this, GHC replaces `Constrd` with a stubbed-out `TyCon`, as explained in this note: {{{ {- Note [Recover from validity error] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We recover from a validity error in a type or class, which allows us to report multiple validity errors. In the failure case we return a TyCon of the right kind, but with no interesting behaviour (makeTyConAbstract). Why? Suppose we have type T a = Fun where Fun is a type family of arity 1. The RHS is invalid, but we want to go on checking validity of subsequent type declarations. So we replace T with an abstract TyCon which will do no harm. See indexed-types/should_fail/BadSock and Trac #10896 Painfully, though, we *don't* want to do this for classes. Consider tcfail041: class (?x::Int) => C a where ... instance C Int The class is invalid because of the superclass constraint. But we still want it to look like a /class/, else the instance bleats that the instance is mal-formed because it hasn't got a class in the head. -} }}} Because of the changes caused by `TypeInType`, the solver now can run while checking type declarations, and the solver ends up seeing the stubbed-out `TyCon`, causing the panic. What should be done about this? Here are some ideas: 1. Some up with a way to deal with the problem described in the Note without fully stubbing out the `TyCon`. For example, the bogus `T` in the note could be transmuted to a `type family T a` with no instances. 2. If there is a validity error in one mutually-recursive group, don't proceed to the next group. This will reduce the number of errors reported in one go. 3. Enlarge the stubbed-out `TyCon`s to be able to make it through the solver without panicking. This shouldn't be too hard, but it seems like the wrong direction of travel. In any case, I'm not assigning the ticket to myself, because I make no guarantees about my ability to finish this work. I just saw that `TcTyCon` (which is the current form of a stubbed-out `TyCon`) was causing trouble so I thought I'd take a look. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12083#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12083: ghc-8.0.1-rc4: tyConRoles sees a TcTyCon -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1-rc4 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Yes. Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mniip): I just hit what I think is an instance of this bug, but in a completely different setup. So here's another testcase I guess: {{{ {-# LANGUAGE GADTs #-} module Bug where class Class a where test :: a -> (Eq a => r) -> r data P a b where Con :: (Class a, a ~ b) => P a b }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12083#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12083: ghc-8.0.1-rc4: tyConRoles sees a TcTyCon -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1-rc4 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Yes. Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3573 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D3573 Comment: Happily, commit 0c9d9dec0a924a4f34f4cff26d004143c028861a (Remove panics for TcTyCon, the fix for #13271) fixed the two programs in this ticket. I've added regression tests for them in Phab:D3573. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12083#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12083: ghc-8.0.1-rc4: tyConRoles sees a TcTyCon
-------------------------------------+-------------------------------------
Reporter: _deepfire | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Compiler (Type | Version: 8.0.1-rc4
checker) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash | Test Case: Yes.
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3573
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott

#12083: ghc-8.0.1-rc4: tyConRoles sees a TcTyCon -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.0.1-rc4 checker) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | typecheck/should_fail/T12083a, | typecheck/should_fail/T12083b Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3573 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: patch => closed * testcase: Yes. => typecheck/should_fail/T12083a, typecheck/should_fail/T12083b * resolution: => fixed * milestone: => 8.2.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12083#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC