Iface type variable out of scope
Christophe Poucet reports the below bug; the 6.6 branch is broken, but the HEAD works.
While working some code I stumbled into a bug with GHC. Basically I have a GADT that has a phantom-type for all but one of it's data constructors. When I try to store a record-type in that tag it gives me a problem due to interfaces when I recompile something against the interface file containing the GADT. Namely, it complains that the type variable is out of scope.
The code in question (after treeing to find out what the actual problem was, namely the combination of GADTs with records) is the following:
-- AST.hs
{-# OPTIONS_GHC -fglasgow-exts #-}
module AST where
data Exp_;
data AST :: * -> * -> * where
Var :: String -> AST Exp_ tag
Tag :: tag -> AST a tag -> AST a tag
-- Main.hs
module Main where
import AST
data Foo = Foo { bar :: Int }
convert :: AST a tag -> AST a Foo
convert t = case t of
Var v -> Tag (Foo 42) $ Var v
Tag t e -> Tag (Foo 42) $ convert e
main = return ()
The bug is easily replicated with the following commands:
> ghc --make Main.hs
-- Works fine
> touch Main.hs
> ghc --make Main.hs
-- The interface for `main:AST'
-- Declaration for AST
-- Constructor AST.Tag:
-- Iface type variable out of scope: tag
-- Cannot continue after interface file error
> rm -f Main.hi Main.o AST.hi AST.o
> ghc --make Main.hs
-- Works fine
Trac metadata
Trac field | Value |
---|---|
Version | 6.6 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | Unknown |
Architecture | Unknown |