Opened 5 years ago

Closed 5 years ago

#9061 closed bug (fixed)

Warnings for redundant imports doesn't take name shadowing into account (Regression)

Reported by: bergmark Owned by:
Priority: normal Milestone: 7.8.3
Component: Compiler Version: 7.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case: module/T9061
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:



module Log where

import Prelude hiding (log)

f :: ()
f = log where log = ()

Compiling this with -Wall On GHC 7.8.2:

> ghc Log.hs -Wall
[1 of 1] Compiling Log              ( Log.hs, Log.o )

Log.hs:3:1: Warning:
    The import of ‘Prelude’ is redundant
      except perhaps to import instances from ‘Prelude’
    To import instances alone, use: import Prelude()

The suggestion is incorrect since removing the import statement gives the following warning:

Log.hs:4:15: Warning:
    This binding for ‘log’ shadows the existing binding
      imported from ‘Prelude’ at Log.hs:1:8-10
      (and originally defined in ‘GHC.Float’)

On GHC 7.6.3 the Reproduction does not give any warnings (which is correct).

Change History (6)

comment:1 Changed 5 years ago by simonpj

Ah yes, thank you. Patch coming.

comment:2 Changed 5 years ago by Simon Peyton Jones <simonpj@…>

In 9f3e39d5f8686e511ffca406a6e056dec4095e53/ghc:

Fix over-zealous unused-import warning

See Note [Un-warnable import decls] in RnNames.

Fixes Trac #9061.

comment:3 Changed 5 years ago by Simon Peyton Jones <simonpj@…>

In 5b73dc5fda1941d51827ea72614782c10a355a3d/ghc:

Second go at fixing #9061

My first attempt introduce a bug in -fprint-minimal-imports, but
fortunately a regression test caught it.

comment:4 Changed 5 years ago by simonpj

Status: newmerge
Test Case: module/T9061

Just about worth merging to 7.8, but hardly a big deal.


comment:5 Changed 5 years ago by thoughtpolice

Milestone: 7.8.3

comment:6 Changed 5 years ago by thoughtpolice

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.