Skip to content

Compiler panic with ill-typed code using implicit parameters

The following snippet produces a compiler panic with GHC 7.7.20121221:

{-# LANGUAGE ImplicitParams #-}

hmm :: ()
hmm = let ?a = True in ?a

main = print hmm

Which results in the error message:

[1 of 1] Compiling Main             ( bug.hs, bug.o )
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 7.7.20121221 for x86_64-unknown-linux):
        ASSERT failed!
    file compiler/typecheck/TcMType.lhs line 407
    Double update of meta tyvar
      t_ajp{tv} [tau[0]]
      Indirect ghc-prim:GHC.Types.Bool{(w) tc 3c}

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

Note that the same snippet compiled with GHC 7.6.1 doesn't panic, and instead gives a type error:

[1 of 1] Compiling Main             ( bug.hs, bug.o )

bug.hs:4:24:
    Couldn't match type `Bool' with `()'
    When using functional dependencies to combine
      ?a::Bool,
        arising from the implicit-parameter bindings for ?a
        at bug.hs:4:7-25
      ?a::(),
        arising from a use of implicit parameter `?a' at bug.hs:4:24-25
    In the expression: ?a
    In the expression: let ?a = True in ?a
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