[GHC] #10117: Change the scheme for reporting redundant imports
GHC
ghc-devs at haskell.org
Wed Jun 8 03:26:00 UTC 2016
#10117: Change the scheme for reporting redundant imports
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.4
Resolution: | Keywords: deprecate
| warning
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by ezyang):
For backwards compatibility, new versions of a module may add new exports
but will not remove exports. The problem with the existing unused imports
warning is that warnings can arise even when an import is upgraded in a
backwards-compatible way (a minor version bump). For example:
{{{
import Prelude
import Control.Applicative ((<*), pure)
}}}
Currently, the `pure` export from `Control.Applicative` is not redundant
if `Prelude` does not export `pure`, but is redundant if it does. But the
addition of `pure` to `Prelude`'s exports is OK for a minor version bump,
which is what makes this warning "annoying". To rule these out, here is
our principle:
* **Backwards-compatible upgrades do not add warnings:** if a module is
warning free, if we upgrade the minor version (as per the PVP) of any of
its imports, the module should continue to be warning free.
Here are warnings which are OK:
* `import A` is not used at all. (For a module to be warning free, it
must use some item from this import; but no matter how we upgrade other
imports, that item will continue to be used.)
* `import A (x)` is not used at all. (Similar.)
* An entity is imported twice explicitly, e.g., `import A (x); import B
(x)`. (This is always redundant (assuming no references to `A.x` or
`B.x`), it doesn't matter what the exports of `A` and `B` are.)
* Two imports are textually redundant, e.g., `import A; import A (x)`.
(Once again, always redundant no matter what the exports.)
Here are some warnings which are NOT ok:
* `import A; import B (x)`, where `A` brings `x` into scope. An old
version of `A` may not export `x` which would make this import-list
warning free.
* `import A; import B`, where `A` and `B` bring `x` into scope. Similar.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10117#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list