Ticket #4047 (closed bug: worksforme)

Opened 3 years ago

Last modified 3 years ago

Incorrect unused-import warning in ghci

Reported by: Berengal Owned by:
Priority: normal Milestone:
Component: GHCi Version: 6.12.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Try to load the following in ghci with -fwarn-unused-imports:

import Prelude hiding (zip)

zip :: [a] -> [b] -> [(a,b)]
zip _ _ = []

It spits out the usual warning for unused imports:

    Warning: The import of `Prelude' is redundant
               except perhaps to import instances from `Prelude'
             To import instances alone, use: import Prelude()

When compiled with ghc --make -fwarn-unused-imports no warning is printed. Also, the following does not generate a warning in ghci:

import Prelude hiding (zip)

zip :: [a] -> [b] -> [(a,b)]
zip _ _ = undefined

I expect ghci and ghc to agree on the warnings unless there's a good reason not to, and I do not expect warnings about declarations to depend on their implementation.

Change History

Changed 3 years ago by simonpj

  • status changed from new to closed
  • resolution set to worksforme

I believe you may be misled by two things:

  • ghc --make does not recompile things that have already been compiled, and that can lead to lack of warnings if you do ghc --make right after (say) your ghci run. Try adding -fforce-recomp
  • undefined is not a keyword: it is simply a named definition that is indeed imported from the Prelude. So there really is a difference between [] and undefined on the RHS of your definition.

Everything seems to be working fine to me. If you still thing there's a bug, by all means re-open this.

Note: See TracTickets for help on using tickets.