summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2015-08-13 20:18:56 +0200
committerBen Gamari <ben@smart-cactus.org>2015-08-13 21:04:32 +0200
commitec68618bac918f365a7760062eb351cba3e4ddb3 (patch)
treeb9683168c5db2ed99d8f0980736d89e0e6c99969
parentd2dd5af433be80464883735f133f3e4dea9c8bd4 (diff)
downloadhaskell-ec68618bac918f365a7760062eb351cba3e4ddb3.tar.gz
Name: Show NameSort in warning
This is quite useful information to know. Spotted when looking at #10769.
-rw-r--r--compiler/basicTypes/Name.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/basicTypes/Name.hs b/compiler/basicTypes/Name.hs
index ce8619a204..506b60fb95 100644
--- a/compiler/basicTypes/Name.hs
+++ b/compiler/basicTypes/Name.hs
@@ -127,6 +127,12 @@ data NameSort
| System -- A system-defined Id or TyVar. Typically the
-- OccName is very uninformative (like 's')
+instance Outputable NameSort where
+ ppr (External _) = text "external"
+ ppr (WiredIn _ _ _) = text "wired-in"
+ ppr Internal = text "internal"
+ ppr System = text "system"
+
-- | BuiltInSyntax is for things like @(:)@, @[]@ and tuples,
-- which have special syntactic forms. They aren't in scope
-- as such.
@@ -216,7 +222,10 @@ isInternalName name = not (isExternalName name)
isHoleName :: Name -> Bool
isHoleName = isHoleModule . nameModule
-nameModule name = nameModule_maybe name `orElse` pprPanic "nameModule" (ppr name)
+nameModule name =
+ nameModule_maybe name `orElse`
+ pprPanic "nameModule" (ppr (n_sort name) <+> ppr name)
+
nameModule_maybe :: Name -> Maybe Module
nameModule_maybe (Name { n_sort = External mod}) = Just mod
nameModule_maybe (Name { n_sort = WiredIn mod _ _}) = Just mod