[commit: ghc] master: Improve error msg for simplifier tick exhaustion (40210c3)

git at git.haskell.org git at git.haskell.org
Fri May 19 22:09:19 UTC 2017


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

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

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

commit 40210c3637d7ac066e0d98c33612b57725708216
Author: David Feuer <david.feuer at gmail.com>
Date:   Fri May 19 18:09:43 2017 -0400

    Improve error msg for simplifier tick exhaustion
    
    Simplifier tick exhaustion is not necessarily "impossible", and
    isn't even always a GHC bug, per se. Improve the error message.
    Furthermore, the simplifier code has access to `IO`, so we can
    throw a proper `IO` exception instead of panicking.
    
    Reviewers: austin, bgamari, angerman
    
    Reviewed By: angerman
    
    Subscribers: angerman, rwbarton, thomie
    
    Differential Revision: https://phabricator.haskell.org/D3597


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

40210c3637d7ac066e0d98c33612b57725708216
 compiler/simplCore/SimplMonad.hs | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/compiler/simplCore/SimplMonad.hs b/compiler/simplCore/SimplMonad.hs
index 8f20637..015ee5c 100644
--- a/compiler/simplCore/SimplMonad.hs
+++ b/compiler/simplCore/SimplMonad.hs
@@ -33,6 +33,7 @@ import Outputable
 import FastString
 import MonadUtils
 import ErrUtils
+import Panic (throwGhcExceptionIO, GhcException (..))
 import BasicTypes          ( IntWithInf, treatZeroAsInf, mkIntWithInf )
 import Control.Monad       ( when, liftM, ap )
 
@@ -211,16 +212,30 @@ tick t = SM (\st_env us sc -> let sc' = doSimplTick (st_flags st_env) t sc
 checkedTick :: Tick -> SimplM ()
 -- Try to take a tick, but fail if too many
 checkedTick t
-  = SM (\st_env us sc -> if st_max_ticks st_env <= mkIntWithInf (simplCountN sc)
-                         then pprPanic "Simplifier ticks exhausted" (msg sc)
-                         else let sc' = doSimplTick (st_flags st_env) t sc
-                              in sc' `seq` return ((), us, sc'))
+  = SM (\st_env us sc ->
+           if st_max_ticks st_env <= mkIntWithInf (simplCountN sc)
+           then throwGhcExceptionIO $
+                  PprProgramError "Simplifier ticks exhausted" (msg sc)
+           else let sc' = doSimplTick (st_flags st_env) t sc
+                in sc' `seq` return ((), us, sc'))
   where
-    msg sc = vcat [ text "When trying" <+> ppr t
-                  , text "To increase the limit, use -fsimpl-tick-factor=N (default 100)"
-                  , text "If you need to do this, let GHC HQ know, and what factor you needed"
-                  , pp_details sc
-                  , pprSimplCount sc ]
+    msg sc = vcat
+      [ text "When trying" <+> ppr t
+      , text "To increase the limit, use -fsimpl-tick-factor=N (default 100)."
+      , space
+      , text "If you need to increase the limit substantially, please file a"
+      , text "bug report and indicate the factor you needed."
+      , space
+      , text "If GHC was unable to complete compilation even"
+               <+> text "with a very large factor"
+      , text "(a thousand or more), please consult the"
+                <+> doubleQuotes (text "Known bugs or infelicities")
+      , text "section in the Users Guide before filing a report. There are a"
+      , text "few situations unlikely to occur in practical programs for which"
+      , text "simplifier non-termination has been judged acceptable."
+      , space
+      , pp_details sc
+      , pprSimplCount sc ]
     pp_details sc
       | hasDetailedCounts sc = empty
       | otherwise = text "To see detailed counts use -ddump-simpl-stats"



More information about the ghc-commits mailing list