summaryrefslogtreecommitdiff
path: root/compiler/GHC/Rename
diff options
context:
space:
mode:
authorAlfredo Di Napoli <alfredo@well-typed.com>2021-07-06 09:39:39 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-07-09 08:46:44 -0400
commit573012c7be49e24ec09a88e078fd22f62f9a4b1d (patch)
tree6dfac9d9c54c43fd786df72b2db6e14350793271 /compiler/GHC/Rename
parentbc38286c57dd9d0e80ef442edc338acdd60e38a3 (diff)
downloadhaskell-573012c7be49e24ec09a88e078fd22f62f9a4b1d.tar.gz
Add the TcRnShadowedName constructor to TcRnMessage
This commit adds the TcRnShadowedName to the TcRnMessage type and it uses it in GHC.Rename.Utils.
Diffstat (limited to 'compiler/GHC/Rename')
-rw-r--r--compiler/GHC/Rename/Utils.hs18
1 files changed, 3 insertions, 15 deletions
diff --git a/compiler/GHC/Rename/Utils.hs b/compiler/GHC/Rename/Utils.hs
index bd5c9240e0..ed1cf40ea4 100644
--- a/compiler/GHC/Rename/Utils.hs
+++ b/compiler/GHC/Rename/Utils.hs
@@ -163,9 +163,9 @@ checkShadowedOccs (global_env,local_env) get_loc_occ ns
check_shadow n
| startsWithUnderscore occ = return () -- Do not report shadowing for "_x"
-- See #3262
- | Just n <- mb_local = complain [text "bound at" <+> ppr (nameSrcLoc n)]
+ | Just n <- mb_local = complain (ShadowedNameProvenanceLocal (nameSrcLoc n))
| otherwise = do { gres' <- filterM is_shadowed_gre gres
- ; complain (map pprNameProvenance gres') }
+ ; when (not . null $ gres') $ complain (ShadowedNameProvenanceGlobal gres') }
where
(loc,occ) = get_loc_occ n
mb_local = lookupLocalRdrOcc local_env occ
@@ -173,12 +173,7 @@ checkShadowedOccs (global_env,local_env) get_loc_occ ns
-- Make an Unqualified RdrName and look that up, so that
-- we don't find any GREs that are in scope qualified-only
- complain [] = return ()
- complain pp_locs = do
- let msg = TcRnUnknownMessage $ mkPlainDiagnostic (WarningWithFlag Opt_WarnNameShadowing)
- noHints
- (shadowedNameWarn occ pp_locs)
- addDiagnosticAt loc msg
+ complain provenance = addDiagnosticAt loc (TcRnShadowedName occ provenance)
is_shadowed_gre :: GlobalRdrElt -> RnM Bool
-- Returns False for record selectors that are shadowed, when
@@ -591,13 +586,6 @@ addNameClashErrRn rdr_name gres
num_non_flds = length non_flds
-shadowedNameWarn :: OccName -> [SDoc] -> SDoc
-shadowedNameWarn occ shadowed_locs
- = sep [text "This binding for" <+> quotes (ppr occ)
- <+> text "shadows the existing binding" <> plural shadowed_locs,
- nest 2 (vcat shadowed_locs)]
-
-
unknownSubordinateErr :: SDoc -> RdrName -> SDoc
unknownSubordinateErr doc op -- Doc is "method of class" or
-- "field of constructor"