Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#1214 closed bug (fixed)

Iface type variable out of scope

Reported by: igloo Owned by: simonpj
Priority: normal Milestone: 6.8.1
Component: Compiler (Type checker) Version: 6.6
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Test Case: gadt23
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


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

Change History (5)

comment:1 Changed 9 years ago by simonpj

  • Owner set to simonpj

Definitely a bug. I will look at it.


comment:2 Changed 9 years ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed

Good report. It was a buglet in the 6.6 branch; I've fixed it.

Ian: the gadt23 test should really be pushed to the 6.6 branch. (But it's hardly worth the bother.)


comment:3 Changed 9 years ago by simonmar

  • Milestone changed from 6.6.2 to 6.8.1

comment:4 Changed 8 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:5 Changed 8 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.