[GHC] #3221: Incorrect "defined but not used" warning for data types using deriving

GHC trac at galois.com
Tue May 12 11:58:39 EDT 2009


#3221: Incorrect "defined but not used" warning for data types using deriving
-----------------------------+----------------------------------------------
Reporter:  NeilMitchell      |          Owner:                  
    Type:  bug               |         Status:  new             
Priority:  normal            |      Component:  Compiler        
 Version:  6.10.2            |       Severity:  normal          
Keywords:                    |       Testcase:                  
      Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
-----------------------------+----------------------------------------------
 Consider:

 {{{

 module Main() where

 import System

 data Foo = Bar | Baz
            deriving (Show,Read)

 main = do
     [x] <- getArgs
     print (read x :: Foo)
 }}}

 When we compile:

 {{{
 $ ghc -c Test.hs -fwarn-unused-binds
 Test.hs:6:11: Warning: Defined but not used: data constructor `Bar'
 Test.hs:6:17: Warning: Defined but not used: data constructor `Baz'
 }}}

 This is incorrect. If a data type derives {{{Read}}}, {{{Enum}}} or
 {{{Bounded}}} (and for {{{Bounded}}}, is either the first or last
 element), then the values are used - even if not by name.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3221>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list