[GHC] #13919: Incorrect unused top binding warning when interacting with GHC.Generics
#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
#13919: Incorrect unused top binding warning when interacting with GHC.Generics -------------------------------------+------------------------------------- Reporter: Taneb | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Generics Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #1954 | Differential Rev(s): Phab:D3704 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * keywords: => Generics * status: new => patch * differential: => Phab:D3704 * related: => #1954 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13919#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13919: Incorrect unused top binding warning when interacting with GHC.Generics -------------------------------------+------------------------------------- Reporter: Taneb | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Generics Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #1954 | Differential Rev(s): Phab:D3704 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"15fcd9adb75b95b32fbe08d066a2ada5f298d667/ghc" 15fcd9ad/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="15fcd9adb75b95b32fbe08d066a2ada5f298d667" Suppress unused warnings for selectors for some derived classes Although derived `Read`, `Show`, and `Generic` instances technically don't //use// the record selectors of the data type for which an instance is being derived, the derived code is affected by the //presence// of record selectors. As a result, we should suppress `-Wunused-binds` for those record selectors when deriving these classes. This is accomplished by threading through more information from `hasStockDeriving`. Test Plan: make test TEST=T13919 Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #13919 Differential Revision: https://phabricator.haskell.org/D3704 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13919#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13919: Incorrect unused top binding warning when interacting with GHC.Generics -------------------------------------+------------------------------------- Reporter: Taneb | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: Generics Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #1954 | Differential Rev(s): Phab:D3704 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed * milestone: => 8.4.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13919#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC