Skip to content
  • Simon Peyton Jones's avatar
    [project @ 2003-02-21 13:27:53 by simonpj] · 84ed91ab
    Simon Peyton Jones authored
    -------------------------------------
    	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.
    84ed91ab