diff options
author | Zubin Duggal <zubin.duggal@gmail.com> | 2021-06-30 15:56:13 +0530 |
---|---|---|
committer | Zubin <zubin.duggal@gmail.com> | 2021-07-13 20:45:44 +0000 |
commit | 9992159318d0f0c3fcf1c1ae060bb15d0b5fc1a8 (patch) | |
tree | 21d54c9455527aebb683ba8df94824759e0b015d /compiler | |
parent | bb8e0df8f4187a4f4d0788dd3da3ef6f9268d378 (diff) | |
download | haskell-wip/no-skolem-panic.tar.gz |
Don't panic on 'no skolem info' and add failing testswip/no-skolem-panic
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/GHC/Tc/Errors.hs | 16 | ||||
-rw-r--r-- | compiler/GHC/Utils/Trace.hs | 10 |
2 files changed, 23 insertions, 3 deletions
diff --git a/compiler/GHC/Tc/Errors.hs b/compiler/GHC/Tc/Errors.hs index c26dce5161..766b88408d 100644 --- a/compiler/GHC/Tc/Errors.hs +++ b/compiler/GHC/Tc/Errors.hs @@ -74,6 +74,7 @@ import GHC.Utils.FV ( fvVarList, unionFV ) import GHC.Data.Bag import GHC.Data.FastString +import GHC.Utils.Trace (pprTraceUserWarning) import GHC.Data.List.SetOps ( equivClasses ) import GHC.Data.Maybe import qualified GHC.Data.Strict as Strict @@ -2944,8 +2945,11 @@ pprSkols ctxt tvs = vcat (map pp_one (getSkolemInfo (cec_encl ctxt) tvs)) where pp_one (UnkSkol, tvs) - = hang (pprQuotedList tvs) - 2 (is_or_are tvs "an" "unknown") + = vcat [ hang (pprQuotedList tvs) + 2 (is_or_are tvs "a" "(rigid, skolem)") + , nest 2 (text "of unknown origin") + , nest 2 (text "bound at" <+> ppr (foldr1 combineSrcSpans (map getSrcSpan tvs))) + ] pp_one (RuntimeUnkSkol, tvs) = hang (pprQuotedList tvs) 2 (is_or_are tvs "an" "unknown runtime") @@ -2979,7 +2983,13 @@ getSkolemInfo _ [] getSkolemInfo [] tvs | all isRuntimeUnkSkol tvs = [(RuntimeUnkSkol, tvs)] -- #14628 - | otherwise = pprPanic "No skolem info:" (ppr tvs) + | otherwise = -- See https://gitlab.haskell.org/ghc/ghc/-/issues?label_name[]=No%20skolem%20info + pprTraceUserWarning msg [(UnkSkol,tvs)] + where + msg = text "No skolem info - we could not find the origin of the following variables" <+> ppr tvs + $$ text "This should not happen, please report it as a bug following the instructions at:" + $$ text "https://gitlab.haskell.org/ghc/ghc/wikis/report-a-bug" + getSkolemInfo (implic:implics) tvs | null tvs_here = getSkolemInfo implics tvs diff --git a/compiler/GHC/Utils/Trace.hs b/compiler/GHC/Utils/Trace.hs index ac29cd6fd8..5da6e6e5d9 100644 --- a/compiler/GHC/Utils/Trace.hs +++ b/compiler/GHC/Utils/Trace.hs @@ -7,6 +7,7 @@ module GHC.Utils.Trace , pprSTrace , pprTraceException , warnPprTrace + , pprTraceUserWarning , trace ) where @@ -71,6 +72,15 @@ warnPprTrace True msg x (msg $$ withFrozenCallStack traceCallStackDoc ) x +-- | For when we want to show the user a non-fatal WARNING so that they can +-- report a GHC bug, but don't want to panic. +pprTraceUserWarning :: HasCallStack => SDoc -> a -> a +pprTraceUserWarning msg x + | unsafeHasNoDebugOutput = x + | otherwise = pprDebugAndThen defaultSDocContext trace (text "WARNING:") + (msg $$ withFrozenCallStack traceCallStackDoc ) + x + traceCallStackDoc :: HasCallStack => SDoc traceCallStackDoc = hang (text "Call stack:") |