diff options
author | simonpj <unknown> | 2003-02-21 13:28:01 +0000 |
---|---|---|
committer | simonpj <unknown> | 2003-02-21 13:28:01 +0000 |
commit | 84ed91abfe3f9df43d5b33e404138e43a574beb8 (patch) | |
tree | 7671ac8068ad7cebc1316a30f3f43e699e354458 /ghc/compiler/hsSyn/HsBinds.lhs | |
parent | dfc75488f4cd1d4f6bf9896f5a901996c77bbc77 (diff) | |
download | haskell-84ed91abfe3f9df43d5b33e404138e43a574beb8.tar.gz |
[project @ 2003-02-21 13:27:53 by simonpj]
-------------------------------------
Improve the "unused binding" warnings
-------------------------------------
We've had a succession of hacks for reporting warnings for
unused bindings. Consider
module M( f ) where
f x = x
g x = g x + h x
h x = x
Here, g mentions itself and h, but is not itself mentioned. So
really both g and h are dead code. We've been getting this wrong
for ages, and every hack so far has failed on some simple programs.
This commit does a much better job. The renamer applied to a bunch
of bindings returns a NameSet.DefUses, which is a dependency-ordered
lists of def/use pairs. It's documented in NameSet.
Given this, we can work out precisely what is not used, in a nice
tidy way.
It's less convenient in the case of type and class declarations, because
the strongly-connected-component analysis can span module boundaries.
So things are pretty much as they were for these.
As usual, there was a lot of chuffing around tidying things up.
I havn't tested it at all thoroughly yet.
Various unrelated import-decl-pruning has been done too.
Diffstat (limited to 'ghc/compiler/hsSyn/HsBinds.lhs')
-rw-r--r-- | ghc/compiler/hsSyn/HsBinds.lhs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ghc/compiler/hsSyn/HsBinds.lhs b/ghc/compiler/hsSyn/HsBinds.lhs index a3d127d6b2..7437f09f29 100644 --- a/ghc/compiler/hsSyn/HsBinds.lhs +++ b/ghc/compiler/hsSyn/HsBinds.lhs @@ -277,9 +277,10 @@ okBindSig :: NameSet -> Sig Name -> Bool okBindSig ns (ClassOpSig _ _ _ _) = False okBindSig ns sig = sigForThisGroup ns sig -okClsDclSig :: NameSet -> Sig Name -> Bool -okClsDclSig ns (Sig _ _ _) = False -okClsDclSig ns sig = sigForThisGroup ns sig +okClsDclSig :: Sig Name -> Bool +okClsDclSig (Sig _ _ _) = False +okClsDclSig (SpecInstSig _ _) = False +okClsDclSig sig = True -- All others OK okInstDclSig :: NameSet -> Sig Name -> Bool okInstDclSig ns (Sig _ _ _) = False |