Skip to content

name shadowing warnings don't trigger on standalone declarations in ghci

The name shadowing warnings in ghci catch shadowing from top-level binds and let statements, but not from standalone declarations (new in 8.0).

rwbarton@morphism:/tmp$ ~/ghc-HEAD/bin/ghci -fwarn-name-shadowing
GHCi, version 8.1.20160212: http://www.haskell.org/ghc/  :? for help
Prelude> a <- return ()
Prelude> a <- return ()

<interactive>:2:1: warning:
    This binding for ‘a’ shadows the existing binding
      defined at <interactive>:1:1
Prelude> let b = return ()
Prelude> let b = return ()

<interactive>:4:5: warning:
    This binding for ‘b’ shadows the existing binding
      defined at <interactive>:3:5
Prelude> c = return ()
Prelude> c = return ()
Prelude>

I'm hoping this can be fixed for 8.0, since I would also very much like to turn on name shadowing warnings in ghci by default (in the interactive flags), to reduce confusion from examples like the below, which is now possible for the first time in 8.0:

Prelude> fact 0 = 1
Prelude> fact n = n * fact (n-1)
Prelude> fact 5
^C^CInterrupted.
Prelude> -- why did it run forever?
Trac metadata
Trac field Value
Version 7.10.3
Type Bug
TypeOfFailure OtherFailure
Priority high
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information