[commit: ghc] master: Name: Show NameSort in warning (ec68618)
git at git.haskell.org
git at git.haskell.org
Thu Aug 13 19:06:01 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/ec68618bac918f365a7760062eb351cba3e4ddb3/ghc
>---------------------------------------------------------------
commit ec68618bac918f365a7760062eb351cba3e4ddb3
Author: Ben Gamari <ben at smart-cactus.org>
Date: Thu Aug 13 20:18:56 2015 +0200
Name: Show NameSort in warning
This is quite useful information to know. Spotted when looking at #10769.
>---------------------------------------------------------------
ec68618bac918f365a7760062eb351cba3e4ddb3
compiler/basicTypes/Name.hs | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/compiler/basicTypes/Name.hs b/compiler/basicTypes/Name.hs
index ce8619a..506b60f 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
More information about the ghc-commits
mailing list