#2056: Incorrect warning about unused import
------------------------+---------------------------------------------------
Reporter: duncan | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 6.8.2 | Severity: normal
Keywords: | Testcase:
Architecture: Unknown | Os: Unknown
------------------------+---------------------------------------------------
In [http://darcs.haskell.org/cabal-install/ 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:
{{{
Hackage/Install.hs:31:0:
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:
{{{
Hackage/Config.hs:33:0:
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. http://darcs.haskell.org/cabal-install/
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2056>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs