ghc warnings messed up in 6.01

Mike Gunter m at ryangunter.com
Sun Dec 7 08:50:14 EST 2003


Simon seems to have agreed that The Right Thing is to treat bindings
with names beginning with an underscore as if they are used w.r.t. to
the bindings they use (they're already treated as used w.r.t. warnings
for themselves.)  With this enhancement (and the other warning fixes
apparently already in HEAD), you should be able to change "ds" to
"_ds" and get no warnings.

BTW (here's the real point of my message :-)), is this enchancement
planned?  For when?  Thanks.

	mike


> has anyone else noticed that the warnings generated by ghc appear to
> have become quite incorrect in many cases?
>
> in particular, the 'defined but not used' warning is generated
> spuriously a lot. almost as if it is being checked after dead code
> elimination and desugaring of some sort..
>
> here is an example which touches all the reproducable bugs I have found.
>
>> module Main(main) where
>> import List(nub)
>> import Monad()
>> 
>> as = repeat 'a'
>> bs = repeat 'b'
>> ds = nub as
>> 
>> cs = [(a,b) | a <- as | b <- bs]
>> 
>> main = print $ take 10 cs        
>
>
> ;ghc -W -fglasgow-exts  Foo.hs
>
> Foo.hs:1:
>     Warning: Module `List' is imported, but nothing from it is used
>              (except perhaps instances visible in `List')
>
> Foo.hs:1:
>     Warning: Module `Monad' is imported, but nothing from it is used
>              (except perhaps instances visible in `Monad')
>
> Foo.hs:7: Warning: Defined but not used: ds
>
> Foo.hs:9: Warning: Defined but not used: b
>
> Foo.hs:9: Warning: Defined but not used: a
>
>
> notice:
>
> 1) it claims nothing is used by List, when 'nub' definatly is being
> used. (technically true, since ds is not used, but this warning is more
> confusing than anything. my first inclination is to delete the import
> line, causing the program to fail to compile, the only fix seems to be
> to track down the root by hand)
>
> 2) it claims Monad is unused, when I specifically imported it with ()
> meaning I don't want any names from it. (i.e., I just want instances)
>
> 3) defined but not used 'ds': yay! the only valid warning.
>
> 4,5) variables bound in parallel list comprehensions always seem to
> generate warnings.  
>
>
> AFAIK, none of these were problems in earlier versions of ghc, they are
> quite anoying as they obscure valid warnings. my guess is some
> desugarings and warning passes were accidentally switched around..
> problem 1 is particularly bad, since a single unused toplevel could
> cascade to generating a ton of warnings, all of which must be sorted
> through to find the actual cause. the others are just anoying as there
> doesn't seem to be a workaround short of disabling warnings.
>
>         John
> -- 
> ---------------------------------------------------------------------------
> John Meacham - California Institute of Technology, Alum. - john at foo.net
> ---------------------------------------------------------------------------
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


More information about the Glasgow-haskell-users mailing list