Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,332
    • Issues 4,332
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 363
    • Merge Requests 363
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #1214

Closed
Open
Opened Mar 11, 2007 by Ian Lynagh <igloo@earth.li>@trac-igloo

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
Assignee
Assign to
6.8.1
Milestone
6.8.1
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#1214