Opened 7 years ago

Closed 7 years ago

#7827 closed bug (fixed)

GHC internal error: `a' is not in scope during type checking, but it passed the renamer

Reported by: guest Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.6.2
Keywords: Cc: thijsalkemade@…, haskell@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case: typecheck/should_compile/T7827
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

In the attached code the following lines give an internal GHC error. At least this should not happen. I also think this is valid code. Removing either type annotation makes this code compile.

bug :: WrappedR Int -> SomeFunction
bug (Wrap node) = case node of
  (Memo' (emptyT :: t a b) memoize (Var m) :: R' a b Int) -> -- also breaks
/Users/alessandro/Documents/Uni/thesis/test/bug-tvar-passed-renamer.hs:14:104:
    GHC internal error: `a' is not in scope during type checking, but it passed the renamer
    tcl_env of environment: [(am4,
                              Identifier[node::R' a b Int, <NotTopLevel>, 1]),
                             (rgs,
                              Identifier[bug::WrappedR Int -> SomeFunction, <NotTopLevel>, 1])]
    In the type `R' a b Int'
    In a pattern type signature: R' a b Int
    In the pattern:
      Memo' (emptyT :: t a b)
            (memoize :: MVar (t a b) -> (a -> b) -> a -> b)
            (Var m :: R' a b Int) :: R' a b Int

Attachments (3)

bug-tvar-passed-renamer.hs (963 bytes) - added by guest 7 years ago.
Code for reproducing the error
0001-Fix-type-variable-scoping-in-nested-pattern-type-sig.patch (1.5 KB) - added by parcs 7 years ago.
0001-Test-Trac-7827.patch (1.1 KB) - added by parcs 7 years ago.

Download all attachments as: .zip

Change History (9)

Changed 7 years ago by guest

Attachment: bug-tvar-passed-renamer.hs added

Code for reproducing the error

comment:1 Changed 7 years ago by xnyhps

Cc: thijsalkemade@… added

comment:2 Changed 7 years ago by AlessandroVermeulen

Cc: haskell@… added

comment:3 Changed 7 years ago by monoidal

Here's a smaller version.

{-# LANGUAGE ScopedTypeVariables #-}
module Main where

bug :: a -> Int
bug ((x :: a) :: a) = undefined

Changed 7 years ago by parcs

Attachment: 0001-Test-Trac-7827.patch added

comment:4 Changed 7 years ago by parcs

Status: newpatch

I've attached a patch (comments included) that fixes this issue (correctly, I hope).

comment:5 Changed 7 years ago by patrick@…

commit 37be6f06feed7351336bf8301fab93ac7c4d3a12

Author: Patrick Palka <patrick@parcs.ath.cx>
Date:   Thu Apr 11 14:00:51 2013 -0400

    Fix type variable scoping in nested pattern type signatures (#7827)

 compiler/rename/RnPat.lhs |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

comment:6 Changed 7 years ago by simonpj

difficulty: Unknown
Resolution: fixed
Status: patchclosed
Test Case: typecheck/should_compile/T7827

Your fix looks exactly right, thank you! I've committed it and the test. Much obliged.

Simon

Note: See TracTickets for help on using tickets.