Skip to content

ghc: panic! -- initTc: unsolved constraints

So this is an interesting bug. If I mistype parse' as parse, /and/ do not have main defined, the error occurs, but not with either individual one.

I'm sure the code sucks, but I wasn't intending for this to end up anywhere, it just happened to trigger the crash.

lijero@desktop:~/code/ab$ ghc AB.hs
[1 of 1] Compiling Main             ( AB.hs, AB.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.2 for x86_64-unknown-linux):
        initTc: unsolved constraints
  WC {wc_insol =
        [W] parse_ay8 :: t_ay7[tau:1] (CHoleCan: parse)
        [W] parse_ayp :: t_ayo[tau:1] (CHoleCan: parse)}

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

data Token = KUnit
           | KApp
           | KLam
           | KVar String

data Ast  = AUnit
          | AApp Ast Ast
          | ALam Ast Ast
          | AVar String

parse' :: [Token] -> ([Token] -> Ast -> Maybe Ast) -> Maybe Ast
parse' (KUnit:xs) fail = fail xs AUnit
-- GHC does not crash when parse is correctly written parse' in both of the below instances
parse' (KApp:xs) fail =
  parse' xs (\ xs' f -> AApp f <$> parse xs' fail)
parse' (KLam:xs) fail =
  parse' xs (\ xs' a -> ALam a <$> parse xs' fail)
parse' (KVar n:xs) fail = fail xs (AVar n)

-- GHC does not crash when main is defined
--main :: IO ()
--main = putStrLn ""

With main defined, GHC correctly reports "variable not in scope". With parse corrected to parse', GHC correctly reports that main is not defined.

Trac metadata
Trac field Value
Version 8.0.2
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