[GHC] #15520: Invalid warning Defined but not used

#15520: Invalid warning Defined but not used -------------------------------------+------------------------------------- Reporter: rik | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- This code gives warning: Defined but not used: data constructor ‘:+++’ {{{#!hs data U = Text :+++ Text x :: U x = "ss" :+++ "ss" }}} Also In prefix notation . -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15520 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15520: Invalid warning Defined but not used -------------------------------------+------------------------------------- Reporter: rik | Owner: (none) Type: bug | Status: infoneeded Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => infoneeded Comment: I'm unable to reproduce the warning you're seeing, but that's only because you've posted an incomplete program (which doesn't compile). What is the export list you're using here? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15520#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15520: Invalid warning Defined but not used -------------------------------------+------------------------------------- Reporter: rik | Owner: (none) Type: bug | Status: infoneeded Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rik): I do not export the data constructor. The export list only contains other identifiers. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15520#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15520: Invalid warning Defined but not used -------------------------------------+------------------------------------- Reporter: rik | Owner: (none) Type: bug | Status: infoneeded Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Do you export `x`? I can get the warning you claim with this program, which does //not// export `x`, for instance: {{{#!hs {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS -Wunused-top-binds #-} module Foo (U) where import Data.Text (Text) data U = Text :+++ Text x :: U x = "ss" :+++ "ss" }}} However, this is correct behavior, since `x` is not used anywhere (and therefore `:+++` is transitively not used), so I'm still not sure what the bug is. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15520#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15520: Invalid warning Defined but not used -------------------------------------+------------------------------------- Reporter: rik | Owner: (none) Type: bug | Status: infoneeded Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rik): Sorry for the delay. Complete program: {{{#!hs {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} module Test(exported) where import Protolude data U = Text :+++ Text x :: U x = "ss" :+++ "ss" exported :: Bool exported = True }}} Gives warnings: {{{ /Users/rik/siemens/autoencoder/src/Test.hs:7:10: warning: [-Wunused-top- binds] Defined but not used: data constructor ‘:+++’ | 7 | data U = Text :+++ Text | ^^^^^^^^^^^^^^ Test.hs:10:1: warning: [-Wunused-top-binds] Defined but not used: ‘x’ | 10 | x = "ss" :+++ "ss" | ^ Ok, one module loaded. }}} I understand from `x` but not from `:+++` -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15520#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15520: Invalid warning Defined but not used -------------------------------------+------------------------------------- Reporter: rik | Owner: (none) Type: bug | Status: infoneeded Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rik): {{{ However, this is correct behavior, since x is not used anywhere (and therefore :+++ is transitively not used) }}} Okay, I see now, I'm confused. `x` is exported so GHC does not know if it is used outside this module, so why this warning? See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/using- warnings.html?highlight=unused-top-binds#ghc-flag--Wunused-top-binds {{{ A variable is regarded as “used” if It is exported, or It appears in the right hand side of a binding that binds at least one used variable that is used }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15520#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15520: Invalid warning Defined but not used -------------------------------------+------------------------------------- Reporter: rik | Owner: (none) Type: bug | Status: infoneeded Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rik): Okay, sorry, this issue can be closed. Sorry for wasting your time. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15520#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15520: Invalid warning Defined but not used -------------------------------------+------------------------------------- Reporter: rik | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: infoneeded => closed * resolution: => invalid -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15520#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC