#3263: Warnings for monadic values not used
------------------------------+---------------------------------------------
 Reporter:  NeilMitchell      |          Owner:                  
     Type:  feature request   |         Status:  new             
 Priority:  normal            |      Milestone:                  
Component:  Compiler          |        Version:  6.10.2          
 Severity:  normal            |     Resolution:                  
 Keywords:                    |       Testcase:                  
       Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
------------------------------+---------------------------------------------
Changes (by batterseapower):

 * cc: [email protected] (added)

Comment:

 I've attached above an implementation of these two flags. The patch
 contains:

  * Code adding -fwarn-wrong-do-bind and -fwarn-unused-do-bind warning
 generation to the compiler
  * Documentation for the two new flags
  * Changes to all the core libraries and GHC itself to prevent the build
 breaking with -Werror
  * Tests for the new warnings

 I found one particularly suspicious instance of code that the warnings
 picked up in GHC:

 {{{
   ; _ <- set_head_fact h a fuel
   ; return fuel }
 }}}

 (compiler/cmm/ZipDataflow.hs:784:22:). set_head_fact returns a Fuel, but
 it is ignored by the single use site. Can this really be what was
 intended?

 When modifying all the libraries, I found a number of functions that often
 required me to write tedious {{{_ <-}}} bindings to suppress the warnings.
 Maybe we should consider providing _ variants of the following:

 {{{
 forkIO -- Returns a ThreadId, which is hardly ever used
 char   -- Returns the character input verbatim, noone cares about it
 string -- Returns the string input verbatim
 evaluate -- Returns the thing on the input. Perhaps we should provide
 force :: a -> IO () as an alternative
 try -- I saw a use of try discarding the result (i.e. ignoring all
 exceptions) in both Cabal and ghc (InteractiveUI.hs)
 throwErrnoIfNull -- One occurence
 }}}

 Internal stuff:

 {{{
 writeBuffer    -- Seen in the encoding code. Return value rarely used.
 installHandler -- Used a lot in GHC code, return value rarely (never?)
 used
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3263#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to