summaryrefslogtreecommitdiff
path: root/compiler/GHC
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC')
-rw-r--r--compiler/GHC/Tc/Errors.hs16
-rw-r--r--compiler/GHC/Utils/Trace.hs10
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:")