#1148: Bad warnings about unused imports that are in fact needed
-------------------------+--------------------------------------------------
    Reporter:  brianh    |       Owner:                       
        Type:  bug       |      Status:  new                  
    Priority:  lowest    |   Milestone:                       
   Component:  Compiler  |     Version:  6.6                  
    Severity:  trivial   |    Keywords:  warning unused import
  Difficulty:  Unknown   |    Testcase:                       
Architecture:  x86       |          Os:  Windows              
-------------------------+--------------------------------------------------
If I compile the following code with the `-W` flag I get a warning about
 the import of `Data.Ix` that shouldn't be generated, since this import is
 actually needed:
 {{{
 {-# OPTIONS_GHC -fglasgow-exts #-}
 module ArrayBoundedU
    ( T
    , create
    , at
    ) where

 import Data.Ix
 import qualified Data.Array.Unboxed as Array
 import Data.Array.Base (unsafeAt)

 newtype T i e = T (Array.UArray i e)

 create :: (Ix i, Bounded i, Array.IArray Array.UArray e) => [(i,e)] -> T i
 e
 create ies = T (Array.array (minBound, maxBound) ies)

 at :: (Ix i, Bounded i, Array.IArray Array.UArray e) => T i e -> i -> e
 at (T a) i = unsafeAt a (index (minBound, maxBound) i)
 }}}
 with a sample `Main`
 {{{
 module Main where

 import Data.Ix
 import ArrayBoundedU

 data I = One | Two | Three
    deriving (Eq, Ord, Ix, Bounded)

 main = do
    let
       a = create [(One, 10::Int), (Two, 20), (Three, 30)]
    putStrLn (show (at a Two))
 }}}
 built using ghc6.6 with:
 {{{
 ghc --make Main.hs -W
 }}}
 I get the warning:
 {{{
 ArrayBoundedU.hs:8:0:
    Warning: Module `Data.Ix' is imported, but nothing from it is used,
       except perhaps instances visible in `Data.Ix'
    To suppress this warning, use: import Data.Ix()
 }}}
 However if I do this then the code doesn't compile at all, since the
 import '''is''' needed.

 This is just a very trivial little thing but it prevents me from being
 able to get my code to compile with no warnings (unless I switched the
 warning off altogether but then something else which really was unused
 would go undetected).

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1148>
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

Reply via email to