Opened 10 years ago

Closed 10 years ago

#3823 closed merge (fixed)

GHC 6.12 breaks combination of records and mutually recursive modules

Reported by: mboes Owned by: igloo
Priority: high Milestone: 6.12.2
Component: Compiler Version: 6.12.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case: T3823
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


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 )

    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.

Change History (4)

comment:1 Changed 10 years ago by simonmar

Milestone: 6.12.2
Priority: normalhigh


comment:2 Changed 10 years ago by simonpj

Owner: set to simonpj

I'm on this.

comment:3 Changed 10 years ago by simonpj

Owner: changed from simonpj to igloo
Type: bugmerge

Good catch, thank you! Easily fixed too

Wed Jan 20 09:42:21 GMT 2010
  * Fix Trac #3823, plus warning police in TcRnDriver
  The immediate reason for this patch is to fix #3823. This was 
  rather easy: all the work was being done but I was returning
  type_env2 rather than type_env3.  
  An unused-veriable warning would have shown this up, so I fixed all
  the other warnings in TcRnDriver.  Doing so showed up at least two
  genuine lurking bugs.  Hurrah.

    M ./compiler/typecheck/TcRnDriver.lhs -54 +60
    M ./compiler/typecheck/TcTyClsDecls.lhs -2 +2

This is worth merging to the 6.12 branch, Ian. And adding a regression test.


comment:4 Changed 10 years ago by igloo

Resolution: fixed
Status: newclosed
Test Case: T3823

I've merged this, but the example fails to build (in both HEAD and 6.12) with this error:

    Couldn't match expected type `A' against inferred type `Bool'
    In the first argument of `y', namely `a'
    In the expression: y a
    In the definition of `b': b = y a

which looks correct to me.

Note: See TracTickets for help on using tickets.