#3779: dodgey warning about redundant class method imports
---------------------------------+------------------------------------------
    Reporter:  duncan            |        Owner:                                
   
        Type:  bug               |       Status:  new                           
   
    Priority:  normal            |    Milestone:                                
   
   Component:  Compiler          |      Version:  6.12.1                        
   
    Keywords:                    |   Difficulty:                                
   
          Os:  Unknown/Multiple  |     Testcase:                                
   
Architecture:  Unknown/Multiple  |      Failure:  Incorrect warning at 
compile-time
---------------------------------+------------------------------------------
 Consider the code:

 {{{
 import qualified Distribution.Text as Text
          ( Text(disp, parse) )

 instance Text.Text ReportLevel where
   disp  = ...
   parse = ...
 }}}

 (This is from `Distribution/Client/BuildReports/Types.hs` in cabal-
 install-0.8.0)

 GHC warns us that:
 {{{
 Distribution/Client/BuildReports/Types.hs:17:0:
     Warning: The import of `Text.disp, Text.parse'
              from module `Distribution.Text' is redundant
 }}}

 But is it really redundant? If we change the import to:
 {{{
 import qualified Distribution.Text as Text
          ( Text )
 }}}
 Then the compile fails because `disp` and `parse` are not visible members
 of the `Text` class.

 Actually it's a bit odd that they become visible when imported qualified
 when the instance decl itself must use non-qualified class method names.
 But I guess that's just a quirk of H98.

 One can get no warning by switching to:
 {{{
 import qualified Distribution.Text as Text
          ( Text(..) )
 }}}
 But that's not very satisfying. I did want to say which class methods I'm
 using.

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