Opened 5 years ago

Closed 5 years ago

#7145 closed bug (fixed)

Incorrect redundant import warning

Reported by: edsko Owned by:
Priority: normal Milestone: 7.6.1
Component: Compiler Version: 7.4.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: rename/should_compile/T7145a, T7145b
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:



module A (SomeDataType(SomeConstructor)) where                                   
  newtype SomeDataType = SomeConstructor ()                                        

module B (SomeDataType(SomeConstructor)) where                                   
  import A(SomeDataType(SomeConstructor))                                          

with -Wall gives

    Warning: The import of `SomeConstructor'
             from module `A' is redundant

but this import is not redundant, I think. Indeed, removing the import gives

    The export item `SomeDataType(SomeConstructor)'
    attempts to export constructors or class methods that are not visible here

Attachments (2)

7145.patch (1.3 KB) - added by pcapriotti 5 years ago.
7145-test.patch (2.0 KB) - added by pcapriotti 5 years ago.

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by pcapriotti

Attachment: 7145.patch added

Changed 5 years ago by pcapriotti

Attachment: 7145-test.patch added

comment:1 Changed 5 years ago by pcapriotti

difficulty: Unknown
Milestone: 7.8.1
Status: newpatch

The problem is that constructors/methods exported as children of a type or class are not currently considered used.

Attached is a patch that fixes that in the case of unqualified exported entities. For qualified entities, the subordinate names can shadow other reader names (as the test case T7145b shows), so we don't add it.

Since the import has to be qualified, anyway, in that case, this should not matter.

comment:2 Changed 5 years ago by simonpj@…

commit 10377bba65de7463b909cc7cd5781a46620f305a

Author: Simon Peyton Jones <>
Date:   Wed Aug 15 14:24:26 2012 +0100

    Fix Trac #7145, by recording uses of constructor "children" in export lists

 compiler/rename/RnNames.lhs |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

comment:3 Changed 5 years ago by simonpj

Status: patchmerge
Test Case: rename/should_compile/T7145a, T7145b

I changed the fix a little; and adopted your tests. Thanks

Can you merge to 7.6 please?


comment:4 Changed 5 years ago by pcapriotti

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