Skip to content

Compiler panic in the presence of cyclic imports

A.hs

module A where

import {-# SOURCE #-} B

data X = X Y

B.hs-boot

module B where

data Y

B.hs

module B where

import A

data Y = Y Int Int

thing :: X -> a
thing (X (Y a b)) = thing (X (Y a b))

C.hs

module C where

import A
import B

panic :: Int -> a
panic x = thing (X (Y x x))

Now try to compile module C:

$ ghc-stage2 -O C
[1 of 4] Compiling B[boot]          ( B.hs-boot, B.o-boot )
[2 of 4] Compiling A                ( A.hs, A.o )
[3 of 4] Compiling B                ( B.hs, B.o )
[4 of 4] Compiling C                ( C.hs, C.o )
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 7.7.20130826 for x86_64-unknown-linux):
        applyTypeToArgs
    main:B.$wthing{v rsQ} [gid]
      @ a{tv ivX} [tv] ww_iwm{v} [lid] ww_iwn{v} [lid]
    a{tv ivX} [tv]

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

I encountered this bug when attempting to compile GHC with GHC -O2 --make.

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