[GHC] #15393: Regression: Detection of unused imports is imprecise (since GHC 8.0.1)

#15393: Regression: Detection of unused imports is imprecise (since GHC 8.0.1) -------------------------------------+------------------------------------- Reporter: SimonHengel | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.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: -------------------------------------+------------------------------------- GHCs detection of unused imports used to be very precise. But apparently this changed with GHC 8.0.1. I already noticed for a while that there is something fishy going on and finally came up with a minimal example. == Steps to reproduce: {{{#!hs -- Bar.hs module Bar (bar, module Control.Monad) where import Control.Monad bar :: Integer bar = 23 }}} {{{#!hs -- Foo.hs module Foo where import Bar import Control.Monad (forM_) foo :: Monad m => [a] -> (a -> m ()) -> m () foo = forM_ baz :: Integer baz = bar }}} {{{ $ ghci -Wall -Werror Foo.hs }}} **Expected result:** The program is reject. **Actual result:** The program was reject by GHC < 8.0.1, however later versions of GHC accept the program. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15393 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15393: Regression: Detection of unused imports is imprecise (since GHC 8.0.1) -------------------------------------+------------------------------------- Reporter: SimonHengel | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.1 Resolution: | 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: | -------------------------------------+------------------------------------- Comment (by mpickering): To be complete, you are suggesting that the import of `Control.Monad` in `Foo.hs` should be warned as redundant? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15393#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15393: Regression: Detection of unused imports is imprecise (since GHC 8.0.1) -------------------------------------+------------------------------------- Reporter: SimonHengel | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.1 Resolution: | 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: | -------------------------------------+------------------------------------- Comment (by SimonHengel):
To be complete, you are suggesting that the import of Control.Monad in Foo.hs should be warned as redundant?
Yes, this is what GHC < 8.0.1 did. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15393#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15393: Regression: Detection of unused imports is imprecise (since GHC 8.0.1) -------------------------------------+------------------------------------- Reporter: SimonHengel | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.1 Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #15393 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => duplicate * related: => #15393 Comment: Thanks for the bug report. This is a duplicate of #13064 (in particular, the `Next2` program in https://ghc.haskell.org/trac/ghc/ticket/13064#comment:12), so I'll close this ticket in favor of that one. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15393#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15393: Regression: Detection of unused imports is imprecise (since GHC 8.0.1) -------------------------------------+------------------------------------- Reporter: SimonHengel | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.1 Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #15393 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by SimonHengel): I'm not too excited about this step for the reason that #13064 is not "very to the point" and was deprioritize. As I see it: - This is a regression - I gave very clear instructions how to reproduce that regression At the very least can somebody with appropriate permissions edit the description of #13064 to make it more to the point? (e.g. the cabal file is not at all necessary for a minimal example + even more importantly it also misses the point that previously rejected programs are accepted now). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15393#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15393: Regression: Detection of unused imports is imprecise (since GHC 8.0.1) -------------------------------------+------------------------------------- Reporter: SimonHengel | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.1 Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #15393 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): You don't need special permissions to edit the description or priority of a Trac ticket; feel free to edit it yourself. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15393#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15393: Regression: Detection of unused imports is imprecise (since GHC 8.0.1) -------------------------------------+------------------------------------- Reporter: SimonHengel | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.1 Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #15393 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I've fixed this properly; see #13064 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15393#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15393: Regression: Detection of unused imports is imprecise (since GHC 8.0.1) -------------------------------------+------------------------------------- Reporter: SimonHengel | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.1 Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #15393 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by SimonHengel): Simon, your are a hero! And I feel I should say sorry for my harsh tone! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15393#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15393: Regression: Detection of unused imports is imprecise (since GHC 8.0.1)
-------------------------------------+-------------------------------------
Reporter: SimonHengel | Owner: (none)
Type: bug | Status: closed
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.4.1
Resolution: duplicate | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
error/warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: #15393 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#15393: Regression: Detection of unused imports is imprecise (since GHC 8.0.1) -------------------------------------+------------------------------------- Reporter: SimonHengel | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.1 Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #15393 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by jrp): Not sure whether this commit is breaking the current {{{validate --slow}}} build: {{{ "inplace/bin/ghc-stage1" -hisuf p_hi -osuf p_o -hcsuf p_hc -static -prof -eventlog -O0 -H64m -Wall -fllvm-fill-undef-with-garbage -Werror -this-unit-id containers-0.6.0.1 -hide-all-packages -i -ilibraries/containers/. -ilibraries/containers/dist-install/build -Ilibraries/containers/dist-install/build -ilibraries/containers/dist- install/build/./autogen -Ilibraries/containers/dist- install/build/./autogen -Ilibraries/containers/include -Ilibraries/containers/dist-install/build/include -optP-include -optPlibraries/containers/dist-install/build/./autogen/cabal_macros.h -package-id array-0.5.2.0 -package-id base-4.12.0.0 -package-id deepseq-1.4.4.0 -package-id ghc-prim-0.5.3 -O2 -Wall -XHaskell98 -O -dcore-lint -dno-debug-output -no-user-package-db -rtsopts -Wno- deprecated-flags -Wnoncanonical-monad-instances -odir libraries/containers/dist-install/build -hidir libraries/containers/dist- install/build -stubdir libraries/containers/dist-install/build -c libraries/containers/./Data/Sequence/Internal.hs -o libraries/containers /dist-install/build/Data/Sequence/Internal.p_o -dyno libraries/containers /dist-install/build/Data/Sequence/Internal.dyn_o libraries/containers/Data/Set/Internal.hs:239:1: error: [-Wunused-imports, -Werror=unused-imports] The import of ‘<>’ from module ‘Data.Semigroup’ is redundant | 239 | import Data.Semigroup (Semigroup((<>), stimes), stimesIdempotentMonoid) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ make[1]: *** [libraries/containers/ghc.mk:4: libraries/containers/dist- install/build/Data/Set/Internal.p_o] Error 1 make[1]: *** Waiting for unfinished jobs.... libraries/containers/Data/IntSet/Internal.hs:198:1: error: [-Wunused- imports, -Werror=unused-imports] The import of ‘<>’ from module ‘Data.Semigroup’ is redundant | 198 | import Data.Semigroup (Semigroup((<>), stimes), stimesIdempotentMonoid) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ libraries/containers/Data/IntSet/Internal.hs:220:1: error: [-Wunused- imports, -Werror=unused-imports] The import of ‘Data.Foldable’ is redundant except perhaps to import instances from ‘Data.Foldable’ To import instances alone, use: import Data.Foldable() | 220 | import Data.Foldable (Foldable()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ make[1]: *** [libraries/containers/ghc.mk:4: libraries/containers/dist- install/build/Data/IntSet/Internal.p_o] Error 1 make: *** [Makefile:128: all] Error 2 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15393#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC