diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2016-04-05 15:15:47 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-04-05 15:46:58 +0200 |
commit | 1e6ec1249b4da88fec9024598c2183e6fc0e96cd (patch) | |
tree | abf58c7119b1f7ec2400e97c15c6e1cdeddd81ee /compiler/rename/RnEnv.hs | |
parent | 2f3b8039e43bd1e2ce7d5af166301441e25b40c4 (diff) | |
download | haskell-1e6ec1249b4da88fec9024598c2183e6fc0e96cd.tar.gz |
Fix misattribution of `-Wunused-local-binds` warnings
This fixes a bug where warnings actually controlled by
- `Opt_WarnUnusedMatches`
- `Opt_WarnUnusedTypePatterns`
- `Opt_WarnUnusedTopBinds`
were incorrectly reported as being controlled by
`Opt_WarnUnusedLocalBinds` as well
This bug was introduced in bb5afd3c274011c5ea302210b4c290ec1f83209c
while implementing #10752
Test Plan: ./validate still running -- testsuite output wiggles expected
Reviewers: barrucadu, quchen, austin, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2077
Diffstat (limited to 'compiler/rename/RnEnv.hs')
-rw-r--r-- | compiler/rename/RnEnv.hs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/compiler/rename/RnEnv.hs b/compiler/rename/RnEnv.hs index a2fd926cba..4c9940d894 100644 --- a/compiler/rename/RnEnv.hs +++ b/compiler/rename/RnEnv.hs @@ -2107,22 +2107,23 @@ warnUnusedTypePatterns = check_unused Opt_WarnUnusedTypePatterns check_unused :: WarningFlag -> [Name] -> FreeVars -> RnM () check_unused flag bound_names used_names - = whenWOptM flag (warnUnusedLocals (filterOut (`elemNameSet` used_names) bound_names)) + = whenWOptM flag (warnUnused flag (filterOut (`elemNameSet` used_names) + bound_names)) ------------------------- -- Helpers warnUnusedGREs :: [GlobalRdrElt] -> RnM () warnUnusedGREs gres = mapM_ warnUnusedGRE gres -warnUnusedLocals :: [Name] -> RnM () -warnUnusedLocals names = do +warnUnused :: WarningFlag -> [Name] -> RnM () +warnUnused flag names = do fld_env <- mkFieldEnv <$> getGlobalRdrEnv - mapM_ (warnUnusedLocal fld_env) names + mapM_ (warnUnused1 flag fld_env) names -warnUnusedLocal :: NameEnv (FieldLabelString, Name) -> Name -> RnM () -warnUnusedLocal fld_env name +warnUnused1 :: WarningFlag -> NameEnv (FieldLabelString, Name) -> Name -> RnM () +warnUnused1 flag fld_env name = when (reportable name) $ - addUnusedWarning Opt_WarnUnusedLocalBinds + addUnusedWarning flag occ (nameSrcSpan name) (text "Defined but not used") where @@ -2133,7 +2134,7 @@ warnUnusedLocal fld_env name warnUnusedGRE :: GlobalRdrElt -> RnM () warnUnusedGRE gre@(GRE { gre_name = name, gre_lcl = lcl, gre_imp = is }) | lcl = do fld_env <- mkFieldEnv <$> getGlobalRdrEnv - warnUnusedLocal fld_env name + warnUnused1 Opt_WarnUnusedTopBinds fld_env name | otherwise = when (reportable name) (mapM_ warn is) where occ = greOccName gre |