scoped type variables: bad error message, and wrong semantics?
With this module (a cut-down version of reify):
{-# OPTIONS -fglasgow-exts #-}
module Foo where
type GTypeFun = forall a . a -> ()
gmapType :: Int -> GTypeFun
gmapType _ (_ :: a) = undefined
GHC gives the rather perplexing error:
Foo.hs:8:12:
The scoped type variables `a' and `a'
are bound to the same type (variable)
Distinct scoped type variables must be distinct
In the pattern: _ :: a
In the definition of `gmapType': gmapType _ (_ :: a) = undefined
Having locations for the two a
s would be useful.
This module gives the same error:
{-# OPTIONS -fglasgow-exts #-}
module Foo where
gmapType :: Int -> (forall a . a -> ())
gmapType _ (_ :: a) = undefined
GHC 6.8.2 accepts both modules.
I don't think that the forall in the type signature should bring a
into scope for the body, as it doesn't bring it into scope for the type signature.
Trac metadata
Trac field | Value |
---|---|
Version | 6.9 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | reify |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | Unknown |
Architecture | Unknown |