Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,399
    • Issues 5,399
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 592
    • Merge requests 592
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #8363
Closed
Open
Issue created Sep 26, 2013 by bergmark@trac-bergmark

Order matters for unused import warnings when reexporting identifiers

Import order seem to change whether unused import warnings trigger when a module re-exports an identifier, with another module importing it and another module exporting the same identifier.

Reproduction:

module Foo ( (<$>) , g  ) where

import Control.Applicative

g :: Int
g = 1
module Main where

import Control.Applicative
import Foo

main :: IO ()
main = print =<< ((+2) <$> return g)
$ ghc -fwarn-unused-imports Main.hs
[1 of 2] Compiling Foo              ( Foo.hs, Foo.o )
[2 of 2] Compiling Main             ( Main.hs, Main.o )
Linking Main ...

If Main is not using g then this gives a warning that the import of Foo is redundant.

If we switch the order of the imports we do get the warning:

module Main where

import Foo
import Control.Applicative

main :: IO ()
main = print =<< ((+2) <$> return g)
> ghc -fwarn-unused-imports Main.hs
[1 of 2] Compiling Foo              ( Foo.hs, Foo.o )
[2 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:4:1:
    Warning: The import of `Control.Applicative' is redundant
               except perhaps to import instances from `Control.Applicative'
             To import instances alone, use: import Control.Applicative()
Linking Main ...

I expected both versions of Main to produce the same warning. Tested on GHC 7.7.20130824 and 7.4.2.

Trac metadata
Trac field Value
Version 7.7
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking