Strange "redundant" import
While working on !1487 (closed) I encountered a very strange issue.
Specifically, Haddock failed with:
compiler/iface/ToIface.hs-boot:6:1: error: [-Wunused-imports, -Werror=unused-imports]
The import of ‘Var’ is redundant
except perhaps to import instances from ‘Var’
To import instances alone, use: import Var()
|
6 | import Var ( TyCoVarBinder )
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
While ToIface.hs-boot
does contain this import
, it most certainly is not redundant (as evidenced by the fact that GHC itself didn't complain, only haddock):
module ToIface where
import {-# SOURCE #-} TyCoRep
import {-# SOURCE #-} IfaceType( IfaceType, IfaceTyCon, IfaceForAllBndr
, IfaceCoercion, IfaceTyLit, IfaceAppArgs )
import Var ( TyCoVarBinder )
import VarEnv ( TidyEnv )
import TyCon ( TyCon )
import VarSet( VarSet )
-- For TyCoRep
toIfaceTypeX :: VarSet -> Type -> IfaceType
toIfaceTyLit :: TyLit -> IfaceTyLit
toIfaceForAllBndr :: TyCoVarBinder -> IfaceForAllBndr
toIfaceTyCon :: TyCon -> IfaceTyCon
toIfaceTcArgs :: TyCon -> [Type] -> IfaceAppArgs
toIfaceCoercionX :: VarSet -> Coercion -> IfaceCoercion
tidyToIfaceTcArgs :: TidyEnv -> TyCon -> [Type] -> IfaceAppArgs
As expected, the module fails to compile if the import of Var
is removed. However, strangely the Haddock issue vanishes if the TyCoRep
import is given an import list:
import {-# SOURCE #-} TyCoRep ( Type, TyLit, Coercion )
This is quite unexpected as TyCoRep
's hs-boot
file doesn't even import Var
, which defines TyCoVarBinder
.