Ticket #5112 (closed bug: invalid)

Opened 2 years ago

Last modified 2 years ago

Incorrect warnings about unqualified imports being redundant

Reported by: sciolizer Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.0.2
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Incorrect warning at compile-time Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Mixing qualified and unqualified imports can confuse the compiler.

To reproduce:

Create the file BadWarning?.hs.

module BadWarning where

import Data.Map
import qualified Data.Map as M

example = empty

Run ghci -W BadWarning.hs, and you get:

BadWarning.hs:4:1:
    Warning: The import of `Data.Map' is redundant
               except perhaps to import instances from `Data.Map'
             To import instances alone, use: import Data.Map()
Ok, modules loaded: BadWarning.

This looks similar to #3992, but that bug does not repro for me, so I think the issue is slightly different.

Change History

Changed 2 years ago by batterseapower

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

Isn't this warning correct? You don't use any names imported from that line. Delete it and your program will still compile!

If you added a type signature or something that uses the M. syntax e.g.

example :: M.Map Int Int

Then the warning goes away, as it should.

Changed 2 years ago by sciolizer

Doh! Yes, that's my mistake. For some reason I kept thinking the warning was referring to line 3 instead of line 4. When I deleted line 3 (as I thought the warning was suggesting), the program would not compile.

This bug report is invalid.

Note: See TracTickets for help on using tickets.