
#13919: Incorrect unused top binding warning when interacting with GHC.Generics -------------------------------------+------------------------------------- Reporter: Taneb | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Incorrect Unknown/Multiple | error/warning at compile-time Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The program {{{#!hs {-# LANGUAGE DeriveGeneric #-} module Main (main) where import Data.Aeson import GHC.Generics data Foo = Foo {bar :: String} deriving Generic instance ToJSON Foo where toJSON = genericToJSON defaultOptions main :: IO () main = print (toJSON (Foo "hello")) }}} emits the warning {{{ UTB.hs:7:17: warning: [-Wunused-top-binds] Defined but not used: ‘bar’ }}} but removing that binding changes the behaviour of the program, as the above prints {{{ Object (fromList [("bar",String "hello")]) }}} but {{{#!hs {-# LANGUAGE DeriveGeneric #-} module Main (main) where import Data.Aeson import GHC.Generics data Foo = Foo String deriving Generic instance ToJSON Foo where toJSON = genericToJSON defaultOptions main :: IO () main = print (toJSON (Foo "hello")) }}} prints {{{ String "hello" }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13919 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler