Skip to content

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

{-# LANGUAGE TypeFamilies, TypeOperators, TemplateHaskell #-}
import Language.Haskell.TH
type family a :<=: b
w = varT (mkName "w")
f = [t|Maybe $w :<=: Int|]

fails with

    GHC internal error: `w' is not in scope during type checking, but it passed the renamer
    tcg_type_env of environment: [(rgd, Type constructor `:<=:')]
    In the expression: w
    In the Template Haskell quotation [t| Maybe $w :<=: Int |]
    In the expression: [t| Maybe $w :<=: Int |]

This testcase was produced by attempting to cut down a case which produces:

ghc: panic! (the 'impossible' happened)
  (GHC version 6.12.1 for x86_64-unknown-linux):
        nameModule way{v a37C}

I don't know whether the underlying cause is the same. In both cases the bug can be avoided by a refactoring:

a x = [t|Maybe $x|]
f = conT ''(:<=:) `appT` a x `appT` [t|Int|]
Trac metadata
Trac field Value
Version 6.12.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
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