[GHC] #8643: Silent name shadowing

GHC ghc-devs at haskell.org
Tue Dec 31 14:23:49 UTC 2013


#8643: Silent name shadowing
-------------------------------------+------------------------------------
        Reporter:  mirpa             |            Owner:
            Type:  feature request   |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:  7.4.1
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:  #5288
-------------------------------------+------------------------------------

Comment (by mirpa):

 {{{
 $ ghc -Wall -fwarn-name-shadowing --make main.hs
 [2 of 2] Compiling Main             ( main.hs, main.o )

 main.hs:9:23:
     Couldn't match expected type `Int -> Maybe a0'
                 with actual type `Maybe b0'
     In the second argument of `(>>=)', namely `foo'
     In the first argument of `(>>=)', namely `bar 1 >>= foo'
     In the expression: bar 1 >>= foo >>= return . (+ 1)

 $ ghc -Wall -fwarn-name-shadowing --make main2.hs
 [2 of 2] Compiling Main             ( main2.hs, main2.o )

 main2.hs:8:1:
     Warning: Top-level binding with no type signature: main :: IO ()

 main2.hs:9:7:
     Warning: This binding for `foo' shadows the existing binding
                imported from `FooLib' at main2.hs:3:1-19
 Linking main2 ...
 }}}

 Compiling {{{main.hs}}} gives no warning about shadowing of {{{foo}}}. I
 must use qualified name first in order to get warning about shadowing as
 shown in {{{main2.hs}}}. I would like to have name shadowing warning when
 compiling {{{main.hs}}} (while I don't see it necessary in case of
 {{{main2.hs}}}).

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


More information about the ghc-tickets mailing list