Ticket #3221 (closed bug: fixed)
Incorrect "defined but not used" warning for data types using deriving
| Reported by: | NeilMitchell | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.12 branch |
| Component: | Compiler | Version: | 6.10.2 |
| Keywords: | Cc: | ndmitchell@… | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | Difficulty: | Unknown | |
| Test Case: | rename/should_compile/T3221 | Blocked By: | |
| Blocking: | Related Tickets: |
Description
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.
Change History
Note: See
TracTickets for help on using
tickets.
