GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:29:38Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/11606name shadowing warnings don't trigger on standalone declarations in ghci2019-07-07T18:29:38Zrwbartonname shadowing warnings don't trigger on standalone declarations in ghciThe 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.20...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?
```
<details><summary>Trac metadata</summary>
| 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 | |
</details>
<!-- {"blocked_by":[],"summary":"name shadowing warnings don't trigger on standalone declarations in ghci","status":"New","operating_system":"","component":"GHCi","related":[],"milestone":"8.0.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.10.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"The name shadowing warnings in ghci catch shadowing from top-level binds and `let` statements, but not from standalone declarations (new in 8.0).\r\n{{{\r\nrwbarton@morphism:/tmp$ ~/ghc-HEAD/bin/ghci -fwarn-name-shadowing\r\nGHCi, version 8.1.20160212: http://www.haskell.org/ghc/ :? for help\r\nPrelude> a <- return ()\r\nPrelude> a <- return ()\r\n\r\n<interactive>:2:1: warning:\r\n This binding for ‘a’ shadows the existing binding\r\n defined at <interactive>:1:1\r\nPrelude> let b = return ()\r\nPrelude> let b = return ()\r\n\r\n<interactive>:4:5: warning:\r\n This binding for ‘b’ shadows the existing binding\r\n defined at <interactive>:3:5\r\nPrelude> c = return ()\r\nPrelude> c = return ()\r\nPrelude>\r\n}}}\r\n\r\nI'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:\r\n{{{\r\nPrelude> fact 0 = 1\r\nPrelude> fact n = n * fact (n-1)\r\nPrelude> fact 5\r\n^C^CInterrupted.\r\nPrelude> -- why did it run forever?\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1rwbartonrwbarton