Skip to content

GHC panics if type in .hs-boot file has greater arity than in the .hs file

Compiling these two mutually-recursive modules triggers a panic:

-- A.hs-boot
module A where

data Blah a b
-- A.hs
module A where
import {-# SOURCE #-} B

data Blah a

foo :: String -> Blah ()
foo = bar
-- B.hs-boot
module B where
import {-# SOURCE #-} A

bar :: String -> Blah () ()
module B where
import A

bar :: String -> Blah () ()
bar = undefined
$ ghc -c --make A.hs
[1 of 4] Compiling A[boot]          ( A.hs-boot, A.o-boot )
[2 of 4] Compiling B[boot]          ( B.hs-boot, B.o-boot )
[3 of 4] Compiling A                ( A.hs, A.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.10.1:
	piResultTys1
  *
  [()]
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1179:37 in ghc:Outputable
        pprPanic, called at compiler/types/Type.hs:1104:5 in ghc:Type

The program should be rejected because the declaration of Blah in A.hs-boot has two type parameters while in A.hs it only has one. But GHC should obviously not panic.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information