#1982: Spurious "defined but not used" warnings for constructors of types 
deriving
Read
-------------------------+--------------------------------------------------
    Reporter:  Eelis-    |       Owner:         
        Type:  bug       |      Status:  new    
    Priority:  low       |   Milestone:         
   Component:  Compiler  |     Version:  6.8.2  
    Severity:  minor     |    Keywords:         
  Difficulty:  Unknown   |    Testcase:         
Architecture:  Unknown   |          Os:  Unknown
-------------------------+--------------------------------------------------
 Consider the following code:

 {{{
   data D = D { ds :: String, db :: Bool }
     deriving (Read, Show)

   main :: IO ()
   main = do
     let s = "D { ds = \"oi\", db = True }"
     print (ds (read s))
     print (db (read s))
 }}}

 With -Wall, ghc emits the following warning:

 {{{
   Warning: Defined but not used: data constructor `D'
 }}}

 I think this warning is not justified, because the D constructor ''is''
 used to parse s.

 The testcase above was derived from a program where D held a bunch of
 configuration fields for the program, and s was read from configuration
 file.

 I would think the fix should be a rule along the lines of:  if a data type
 derives from Read, then all of its constructors and field names are
 considered used.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1982>
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