[project @ 2003-02-21 13:27:53 by simonpj]
authorsimonpj <unknown>
Fri, 21 Feb 2003 13:28:01 +0000 (13:28 +0000)
committersimonpj <unknown>
Fri, 21 Feb 2003 13:28:01 +0000 (13:28 +0000)
commit84ed91abfe3f9df43d5b33e404138e43a574beb8
tree7671ac8068ad7cebc1316a30f3f43e699e354458
parentdfc75488f4cd1d4f6bf9896f5a901996c77bbc77
[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.
25 files changed:
ghc/compiler/basicTypes/NameSet.lhs
ghc/compiler/hsSyn/HsBinds.lhs
ghc/compiler/prelude/TysWiredIn.lhs
ghc/compiler/rename/RnBinds.lhs
ghc/compiler/rename/RnEnv.lhs
ghc/compiler/rename/RnExpr.lhs
ghc/compiler/rename/RnHiFiles.lhs
ghc/compiler/rename/RnIfaces.lhs
ghc/compiler/rename/RnNames.lhs
ghc/compiler/rename/RnSource.hi-boot-5
ghc/compiler/rename/RnSource.hi-boot-6
ghc/compiler/rename/RnSource.lhs
ghc/compiler/rename/RnTypes.lhs
ghc/compiler/typecheck/Inst.lhs
ghc/compiler/typecheck/TcClassDcl.lhs
ghc/compiler/typecheck/TcDeriv.lhs
ghc/compiler/typecheck/TcEnv.lhs
ghc/compiler/typecheck/TcExpr.lhs
ghc/compiler/typecheck/TcIfaceSig.lhs
ghc/compiler/typecheck/TcInstDcls.lhs
ghc/compiler/typecheck/TcMonoType.lhs
ghc/compiler/typecheck/TcRnDriver.lhs
ghc/compiler/typecheck/TcRnTypes.lhs
ghc/compiler/typecheck/TcTyDecls.lhs
ghc/compiler/typecheck/TcUnify.lhs