#4977: Warning about unqualified implicit imports
---------------------------------+------------------------------------------
    Reporter:  Lemming           |        Owner:              
        Type:  feature request   |       Status:  new         
    Priority:  normal            |    Milestone:              
   Component:  Compiler          |      Version:  7.0.1       
    Keywords:                    |     Testcase:              
   Blockedby:                    |   Difficulty:              
          Os:  Unknown/Multiple  |     Blocking:              
Architecture:  Unknown/Multiple  |      Failure:  None/Unknown
---------------------------------+------------------------------------------

Comment(by Lemming):

 My attempt for a specification:

 Add the option -fwarn-unqualified-imports that make GHC do the following:
 Whenever GHC encounters import statements of one of the following types
 {{{
 module Main where

 import Top.A
 import Top.A hiding (x, y, z)
 import Top.A as A
 import Top.A as A hiding (x, y, z)
 }}}
 it shall emit a warning like:
 {{{
 Main.hs:3:0:
     Warning: Unqualified implicit import of module Top.A
              which risks name collisions if identifiers are added to Top.A
 in the future.
              Better write
                 import qualified Top.A as A
              or
                 import Top.A (x, y, z, ...)
 }}}

 Ideally the second suggested import statement (import Top.A (...))
 contains all identifiers from Top.A that are actually used in Main. Then
 the suggested import statement can be copied into Main and Main can be
 compiled without further modifications.

 The option -Wall may not include this warning, since some people prefer
 those kinds of imports.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4977#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to