
#13187: Strange debug output printed: isPredTy Const Int (,) Bool Char -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by RyanGlScott: @@ -6,1 +6,0 @@ - {-# LANGUAGE TemplateHaskell #-} @@ -10,3 +9,3 @@ - test36_expand = $([| let f :: Const Int (,) Bool Char -> Char - f = snd in - f |]) + + f :: Const Int (,) Bool Char -> Char + f = snd New description: I noticed this when debugging an issue in `th-desugar`. If you have this file: {{{#!hs {-# LANGUAGE PolyKinds #-} module Bug where type Const a b = b f :: Const Int (,) Bool Char -> Char f = snd }}} And compile it on GHC HEAD with `-ddump-tc-trace` enabled, even if you redirect the output of `-ddump-tc-trace` to a file with `-ddump-to-file`, GHC will still print what appears to be debugging messages! {{{ $ ~/Software/ghc3/inplace/bin/ghc-stage2 Bug.hs -ddump-to-file -fforce- recomp -ddump-tc-trace [1 of 1] Compiling Bug ( Bug.hs, Bug.o ) isPredTy Const Int (,) Bool Char }}} The source of that `isPredTy` message is in `Type` ([http://git.haskell.org/ghc.git/blob/3eebd1f5fd56689baa63fcc63b7f4bde0ae70d0b... here]): {{{#!hs go_k :: Kind -> [KindOrType] -> Bool -- True <=> ('k' applied to 'kts') = Constraint go_k k [] = isConstraintKind k go_k k (arg:args) = case piResultTy_maybe k arg of Just k' -> go_k k' args Nothing -> pprTrace "isPredTy" (ppr ty) False -- This last case should not happen; but it does if we -- we call isPredTy during kind checking, especially if -- there is actually a kind error. Example that showed -- this up: polykinds/T11399 }}} Several things stand out here: 1. Should we be using `pprTrace` this way? 2. Given that the comment says that "This last case should not happen", is this program indicative of a bug? Or perhaps this code really can be legitimately reached, and the comment should be updated to reflect this? FWIW, `polykinds/T11399` exhibits the same issue: {{{ $ ~/Software/ghc3/inplace/bin/ghc-stage2 Bug2.hs -ddump-to-file -fforce- recomp -ddump-tc-trace [1 of 1] Compiling T11399 ( Bug2.hs, Bug2.o ) isPredTy a_aCn[sk:1] * isPredTy a_aCn[sk:1] * isPredTy a_aCn[sk:1] * isPredTy a_aCn[sk:1] * isPredTy a_aCn[sk:1] * isPredTy a_aCn[sk:1] * isPredTy a_aCn[sk:1] * isPredTy a_aCn[sk:1] * isPredTy a_aCn[sk:1] * isPredTy a_aCn[sk:1] * isPredTy a_aCn[sk:1] * isPredTy a_aCn[sk:1] * isPredTy a_aCn[sk:1] * Bug2.hs:10:32: error: • Couldn't match kind ‘*’ with ‘GHC.Types.RuntimeRep’ When matching kinds a :: * -> * TYPE :: GHC.Types.RuntimeRep -> * Expected kind ‘* -> *’, but ‘UhOh a’ has kind ‘a * -> *’ • In the first argument of ‘Functor’, namely ‘(UhOh a)’ In the instance declaration for ‘Functor (UhOh a)’ | 10 | instance Functor a => Functor (UhOh a) where | ^^^^^^ }}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13187#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler