Opened 5 years ago

Closed 4 years ago

#7778 closed bug (fixed)

kindFunResult panic with => inside a constraint

Reported by: monoidal Owned by: simonpj
Priority: normal Milestone: 7.8.1
Component: Compiler (Type checker) Version: 7.6.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: typecheck/should_fail/T7778
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Following type (found by arkeet on #haskell) causes kindFunResult panic in 7.6 and HEAD:

v :: ((Num Int => Num) ()) => ()
v = v

In a probably related issue,

Prelude> :set -XFlexibleContexts -XRankNTypes
Prelude> type T = Num Int => Num Bool
Prelude> :k T
T :: Constraint
Prelude> :k Num Int => Num Bool
Num Int => Num Bool :: *

Change History (4)

comment:1 Changed 4 years ago by igloo

difficulty: Unknown
Milestone: 7.8.1
Owner: set to simonpj
[1 of 1] Compiling Main             ( q.hs, interpreted )
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 7.7.20130409 for x86_64-unknown-linux):
<<details unavailable>>

comment:2 Changed 4 years ago by parcs

FYI the first code snippet produces a different panic with a DEBUG build of GHC.

Panic with DEBUG build:

ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 7.7.20130416 for x86_64-unknown-linux):
        ASSERT failed!
    file compiler/types/Type.lhs line 1623
    base:GHC.Num.Num{tc 2b} ghc-prim:GHC.Types.Int{(w) tc 3J} =>
    base:GHC.Num.Num{tc 2b}
    ghc-prim:GHC.Prim.*{(w) tc 34d}
    -> ghc-prim:GHC.Prim.Constraint{(w) tc 34s}

Panic with non-DEBUG buird:

[1 of 1] Compiling Main             ( q.hs, interpreted )
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 7.7.20130421 for x86_64-unknown-linux):
        kindFunResult ghc-prim:GHC.Prim.*{(w) tc 34d}

comment:3 Changed 4 years ago by simonpj@…

commit d3149f6096a987e94d4989e537c1a133bcbb9a6f

Author: Simon Peyton Jones <>
Date:   Mon Apr 29 17:26:17 2013 +0100

    Tighten up on the kind checking for foralls
    In particular,
       (forall a. Num a => ...)
    always has kind *, becuase the "=>" really is a function.
    It turned out that this was at the bottom of the crash in Trac #7778,
    which is now fixed

 compiler/typecheck/TcHsType.lhs   |   31 ++++++++++++++++++++++++-------
 compiler/typecheck/TcValidity.lhs |   16 +++++++++-------
 2 files changed, 33 insertions(+), 14 deletions(-)

comment:4 Changed 4 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: typecheck/should_fail/T7778

Thanks for the test case. It showed up a real infelicity.


Note: See TracTickets for help on using tickets.