Skip to content

Assertion failure with cyclic import

Given three files

A.hs

module A where

A.hs-boot

module A where

import B

B.hs

module B where

import {-# SOURCE #-} A

we get

$ ./stage1/bin/ghc B
ghc: panic! (the 'impossible' happened)
  GHC version 9.9.20231110:
	ASSERT failed!
  Build plan missing nodes:
  PLAN: 2
  GRAPH: 3
  Call stack:
      CallStack (from HasCallStack):
        assertPpr, called at compiler/GHC/Driver/Make.hs:669:5 in ghc-9.9-inplace:GHC.Driver.Make
  CallStack (from HasCallStack):
    panic, called at compiler/GHC/Utils/Error.hs:511:29 in ghc-9.9-inplace:GHC.Utils.Error

If assertions are disabled, the error message is poor:

$ ./stage1/bin/ghc B
Unexpected non-cycle [main:B [main:A {-# SOURCE #-}],
                      main:A [main:A {-# SOURCE #-}]]

GHC 9.2 is better:

$ ghc B
Module imports form a cycle:
        module ‘B’ (B.hs)
        imports module ‘A’ (./A.hs-boot)
  which imports module ‘B’ (B.hs)
Edited by Krzysztof Gogolewski
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information