[GHC] #15215: GHC HEAD internal error when FlexibleContexts isn't enabled
#15215: GHC HEAD internal error when FlexibleContexts isn't enabled -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 (Type checker) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time Unknown/Multiple | crash or panic Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The following code produces a GHC internal error on GHC HEAD: {{{#!hs {-# LANGUAGE GADTs #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeInType #-} module Bug where import Data.Kind data A :: Type -> Type where MkA :: Show (Maybe a) => A a data SA :: forall a. A a -> Type where SMkA :: SA MkA }}} {{{ $ ~/Software/ghc5/inplace/bin/ghc-stage2 Bug.hs[1 of 1] Compiling Bug ( Bug.hs, Bug.o ) Bug.hs:9:3: error: • Non type-variable argument in the constraint: Show (Maybe a) (Use FlexibleContexts to permit this) • In the definition of data constructor ‘MkA’ In the data type declaration for ‘A’ | 9 | MkA :: Show (Maybe a) => A a | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Bug.hs:12:14: error: • GHC internal error: ‘MkA’ is not in scope during type checking, but it passed the renamer tcl_env of environment: [rqU :-> ATcTyCon SA :: forall a. A a -> *, rsV :-> APromotionErr RecDataConPE] • In the first argument of ‘SA’, namely ‘MkA’ In the type ‘SA MkA’ In the definition of data constructor ‘SMkA’ | 12 | SMkA :: SA MkA | ^^^ }}} Enabling `FlexibleContexts` causes the internal error to go away. This is a regression from GHC 8.4, which does not give an internal error. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15215> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15215: GHC HEAD internal error when FlexibleContexts isn't enabled -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler (Type | Version: 8.4.3 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"2f6069ccf21d7be0e09016896238f417d2492ffa/ghc" 2f6069c/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="2f6069ccf21d7be0e09016896238f417d2492ffa" Make better "fake tycons" in error recovery Consider (Trac #15215) data T a = MkT ... data S a = ...T...MkT.... If there is an error in the definition of 'T' we add a "fake type constructor" to the type environment, so that we can continue to typecheck 'S'. But we /were not/ adding a fake anything for 'MkT' and so there was an internal error when we met 'MkT' in the body of 'S'. The fix is to add fake tycons for all the 'implicits' of 'T'. This is done by mk_fake_tc in TcTyClsDecls.checkValidTyCl, which now returns a /list/ of TyCons rather than just one. On the way I did some refactoring: * Rename TcTyDecls.tcAddImplicits to tcAddTyConsToGblEnv and make it /include/ the TyCons themeselves as well as their implicits * Some incidental refactoring about tcRecSelBinds. The main thing is that I've avoided creating a HsValBinds that we immediately decompose. That meant moving some deck chairs around. NB: The new error message for the regression test T15215 has the opaque error "Illegal constraint in a type:", flagged in Trac #14845. But that's the fault of the latter ticket. The fix here not to blame. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15215#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15215: GHC HEAD internal error when FlexibleContexts isn't enabled -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler (Type | Version: 8.4.3 checker) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: crash or panic | dependent/should_fail/T15215 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * testcase: => dependent/should_fail/T15215 * resolution: => fixed Comment: Thanks for reporting this -- now fixed. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15215#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC