[commit: ghc] master: Convert pprTrace in isPredTy to a WARN (bc42e2b)

git at git.haskell.org git at git.haskell.org
Sat Jan 28 22:44:18 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/bc42e2b03a87e3f6c0d24584382f281c6580801b/ghc

>---------------------------------------------------------------

commit bc42e2b03a87e3f6c0d24584382f281c6580801b
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Sat Jan 28 16:54:11 2017 -0500

    Convert pprTrace in isPredTy to a WARN
    
    Summary:
    There was a `pprTrace` in `isPredTy` that could fire under certain
    scenarios, causing normal GHC users to see debugging output. This turns it into
    a less chatty `WARN`, and expounds on the comment below it to add the scenario
    in #13187 which triggered the `pprTrace`.
    
    Reviewers: goldfire, austin, bgamari
    
    Reviewed By: goldfire, bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D3033
    
    GHC Trac Issues: #13187


>---------------------------------------------------------------

bc42e2b03a87e3f6c0d24584382f281c6580801b
 compiler/types/Type.hs | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs
index b611786..ad1b11f 100644
--- a/compiler/types/Type.hs
+++ b/compiler/types/Type.hs
@@ -1525,12 +1525,26 @@ isPredTy ty = go ty []
     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)
+                          Nothing -> WARN( True, text "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
+       -- This last case shouldn't happen under most circumstances. It can
+       -- occur if we call isPredTy during kind checking, especially if one
+       -- of the following happens:
+       --
+       -- 1. There is actually a kind error.  Example in which this showed up:
+       --    polykinds/T11399
+       -- 2. A type constructor application appears to be oversaturated. An
+       --    example of this occurred in GHC Trac #13187:
+       --
+       --      {-# LANGUAGE PolyKinds #-}
+       --      type Const a b = b
+       --      f :: Const Int (,) Bool Char -> Char
+       --
+       --    This code is actually fine, since Const is polymorphic in its
+       --    return kind. It does show that isPredTy could possibly report a
+       --    false negative if a constraint is similarly oversaturated, but
+       --    it's hard to do better than isPredTy currently does without
+       --    zonking, so we punt on such cases for now.
 
 isClassPred, isEqPred, isNomEqPred, isIPPred :: PredType -> Bool
 isClassPred ty = case tyConAppTyCon_maybe ty of



More information about the ghc-commits mailing list