Opened 3 years ago

Closed 3 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 Revisions:

Description

Compiling

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

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

with -Wall gives

B.hs:3:1:
    Warning: The import of `SomeConstructor'
             from module `A' is redundant

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

B.hs:1:11:
    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 3 years ago.
7145-test.patch (2.0 KB) - added by pcapriotti 3 years ago.

Download all attachments as: .zip

Change History (6)

Changed 3 years ago by pcapriotti

Changed 3 years ago by pcapriotti

comment:1 Changed 3 years ago by pcapriotti

  • difficulty set to Unknown
  • Milestone set to 7.8.1
  • Status changed from new to patch

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 3 years ago by simonpj@…

commit 10377bba65de7463b909cc7cd5781a46620f305a

Author: Simon Peyton Jones <[email protected]>
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 3 years ago by simonpj

  • Status changed from patch to merge
  • Test Case set to rename/should_compile/T7145a, T7145b

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

Can you merge to 7.6 please?

Simon

comment:4 Changed 3 years ago by pcapriotti

  • Milestone changed from 7.8.1 to 7.6.1
  • Resolution set to fixed
  • Status changed from merge to closed
Note: See TracTickets for help on using tickets.