Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#2056 closed bug (duplicate)

Incorrect warning about unused import

Reported by: duncan Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


In cabal-install in four modules we get an incorrect warning about an import that is unused when it is in fact used. It is also used directly or indirectly by exported functions.

The warnings are all of the same form. Here is one:

    Warning: Module `Distribution.Simple.Compiler' is imported, but nothing from it is used,
               except perhaps instances visible in `Distribution.Simple.Compiler'
             To suppress this warning, use: import Distribution.Simple.Compiler()

We import from that module only once with

import Distribution.Simple.Compiler (Compiler, PackageDB)

Both the Compiler and PackageDB types are used in the type signature for install which is directly exported.

install :: Verbosity
        -> PackageDB
        -> [Repo]
        -> Compiler
        -> ProgramConfiguration
        -> Cabal.ConfigFlags
        -> [UnresolvedDependency]
        -> IO ()

The problem is not restricted to unused types. This import:

import Distribution.Compiler (CompilerFlavor(..), defaultCompilerFlavor)

gives us the following warning:

    Warning: Module `Distribution.Compiler' is imported, but nothing from it is used,
               except perhaps instances visible in `Distribution.Compiler'
             To suppress this warning, use: import Distribution.Compiler()

Which is used in a value

defaultCompiler :: CompilerFlavor
defaultCompiler = fromMaybe GHC defaultCompilerFlavor

This value is used indirectly by an exported function.

It is not obvious to me what is special about these imports that gives us these incorrect warnings. (Except that they have the module name "Compiler".)

Initially this looks similar to ticket #1148, however that was diagnosed as being related to qualified imports. This does not appear to be the same.

It should be possible to reproduce these using ghc-6.8.2 and the cabal-install code from darcs.

Change History (4)

comment:1 Changed 12 years ago by igloo

difficulty: Unknown
Resolution: duplicate
Status: newclosed

Thanks for the report. However, this looks the same as #1148 to me; you do

import qualified Distribution.Simple.Setup as Cabal

and Distribution.Simple.Setup exports Compiler and PackageDB.

comment:2 Changed 12 years ago by duncan

Yup. Quite right. I didn't spot that. That qualified import is there in each of the modules where we get that warning.

comment:3 Changed 11 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:4 Changed 11 years ago by simonmar

Operating System: UnknownUnknown/Multiple
Note: See TracTickets for help on using tickets.