Skip to content

GHC 6.12 breaks combination of records and mutually recursive modules

Take the following code for two mutually recursive modules A and B:

module A where

import B

data A = X { x :: Bool } | Y

y :: A -> A
y = \_ -> Y

-- A.hs-boot
module A where

data A = X { x :: Bool } | Y

y :: A -> A

module B where

import {-# SOURCE #-} A

data B = A A

a = x (X True)
b = y a

Compiling this code with ghc --make or ghci gives:

[1 of 3] Compiling A[boot]          ( A.hs-boot, A.o-boot )
[2 of 3] Compiling B                ( B.hs, B.o )

B.hs:7:4:
    Can't find interface-file declaration for variable x
      Probable cause: bug in .hi-boot file, or inconsistent .hi file
      Use -ddump-if-trace to get an idea of which file caused the error
    In the expression: x (X True)
    In the definition of `a': a = x (X True)

This code used to work in GHC 6.10.

Note that this issue breaks the build of the hmk package on Hackage. Doubtless other packages making use of mutually recursive modules hit this snag too.

Trac metadata
Trac field Value
Version 6.12.1
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