Opened 3 months ago

Last modified 2 months ago

#15984 new bug

Backpack accepts ill-kinded instantiations. Can cause GHC panic

Reported by: aaronvargo Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.6.2
Keywords: backpack Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash or panic Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by aaronvargo)

Given the following:

{-# language KindSignatures #-}
signature A where

data A :: *
module Foo where

import A

foo :: A -> A
foo = id
module IllKindedA where

type A = Maybe

GHC allows the signature A to be instantiated with IllKindedA:

mixins: foo (Foo as Bug) requires (A as IllKindedA)

Using the resulting module can cause odd errors or a panic. E.g. the following causes a panic:

module Bar where

import Bug

bar = foo
ghc: panic! (the 'impossible' happened)
  (GHC version 8.6.2 for x86_64-unknown-linux):
  A :: * -> *
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
        pprPanic, called at compiler/types/Type.hs:2049:18 in ghc:Type

Change History (2)

comment:1 Changed 3 months ago by aaronvargo

Description: modified (diff)

Oops, it seems this only happened because I foolishly had IllKindedA in the same library as A:

library foo
  build-depends: base
  signatures: A
  exposed-modules: Foo, IllKindedA

library bar
  build-depends: base, foo
  exposed-modules: Bar
  mixins: foo (Foo as Bug) requires (A as IllKindedA)

It's still a bug though.

comment:2 Changed 2 months ago by bgamari

Milestone: 8.6.3

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.