Skip to content

Internal error using redundant forall with default signature

{-# LANGUAGE ScopedTypeVariables, DefaultSignatures #-}

class Foo x where
  foo :: forall a . x a -> x a
  default foo :: forall a . x a -> x a
  foo x = go
    where go :: x a
          go = undefined

GHC (7.8.3 and 8.0.1) chokes on the above with the message

Buggy.hs:7:19: error:
    • GHC internal error: ‘a’ is not in scope during type checking, but it passed the renamer
      tcl_env of environment: [aoY :-> Type variable ‘x’ = x,
                               ap0 :-> Type variable ‘a’ = a,
                               ap1 :-> Identifier[x::x a, <NotTopLevel>]]
    • In the first argument of ‘x’, namely ‘a’
      In the type signature:
        go :: x a
      In an equation for ‘foo’:
          foo x
            = go
            where
                go :: x a
                go = undefined

If I remove the redundant forall it works fine:

class Foo x where
  foo :: x a -> x a
  default foo :: forall a . x a -> x a
  foo x = go
    where go :: x a
          go = undefined
Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information