Skip to content

Interface file error with GADT and -O1

I've tried to simplify this as much as possible. In particular, the bug goes away if -O1 is removed.

module Bug1 where

data A a where
  MkA :: A ()

class C w where
  f :: forall a . w a -> Maybe a

instance C A where
  f MkA  = Just ()
module Bug2 where
import Bug1

f' :: A a -> Maybe a
f' = f

Run with this:

{{{ #!/bin/sh rm -f *.hi *.o ghc --version ghc -c -XGADTs -XRankNTypes -O1 Bug1.hs ghc -c -XGADTs -XRankNTypes -O1 Bug2.hs }}}

This is the result I get:

The Glorious Glasgow Haskell Compilation System, version 6.8.2
Bug1.hi
Declaration for a:
  Iface type variable out of scope:  a
Cannot continue after interface file error
Trac metadata
Trac field Value
Version 6.8.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
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