GHC HEAD internal error when FlexibleContexts isn't enabled
The following code produces a GHC internal error on GHC HEAD:
{-# 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.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.4.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |