[GHC] #11606: name shadowing warnings don't trigger on standalone declarations in ghci

#11606: name shadowing warnings don't trigger on standalone declarations in ghci -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: GHCi | Version: 7.10.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- 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? }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11606 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11606: name shadowing warnings don't trigger on standalone declarations in ghci -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I didn't even know you could say {{{ Prelude> c = "Hello" }}} It seems entirely un-documented in the user manual. It would be great if someone could document it, when implementing Reid's suggestion. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11606#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11606: name shadowing warnings don't trigger on standalone declarations in ghci -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * cc: roshats (added) Comment:
Prelude> c = "Hello" That feature was implemented by Roman Shatsov in #7253 (b98ff3ccb14e36145404f075349c8689762a2913). The patch includes documentation updates.
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11606#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11606: name shadowing warnings don't trigger on standalone declarations in ghci -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: rwbarton Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by rwbarton): * owner: => rwbarton Comment: I realized the reason is that we never test names defined at top level for shadowing (shadowing names imported from other modules). So the plan is this. Add a flag `-Wtop-level-name-shadowing` that checks top-level bindings for shadowing (like defining `id`). Then make it default in the ghci interactive flags (only). (No, I do not suggest making it part of `-Wall`.) Validating that currently, then will post on Phab. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11606#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11606: name shadowing warnings don't trigger on standalone declarations in ghci -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: rwbarton Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Great, looking forward to it. Thanks -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11606#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11606: name shadowing warnings don't trigger on standalone declarations in ghci -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: rwbarton Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Reid, I don't believe this ever made it up onto Phab. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11606#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11606: name shadowing warnings don't trigger on standalone declarations in ghci -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: rwbarton Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * milestone: 8.0.1 => 8.0.2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11606#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11606: name shadowing warnings don't trigger on standalone declarations in ghci -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: rwbarton Type: bug | Status: new Priority: high | Milestone: 8.0.3 Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.0.2 => 8.0.3 Comment: Looks like this won't happen for 8.0.2. Rwbarton, do you suppose you could post your patch? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11606#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11606: name shadowing warnings don't trigger on standalone declarations in ghci -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: rwbarton Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.2.1 => 8.4.1 Comment: Also not happening for 8.2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11606#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11606: name shadowing warnings don't trigger on standalone declarations in ghci -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #16096 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by osa1): * owner: rwbarton => (none) * related: => #16096 Comment: My fix for #16096 (Phab:D5473) which treats `x = y` as `let x = y` fixes this: {{{ ~ $ ghc-stage2 --interactive -Wall GHCi, version 8.7.20181226: https://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/omer/rcbackup/.ghci λ:1> x = 1 λ:2> x = 1 <interactive>:2:1: warning: [-Wname-shadowing] This binding for ‘x’ shadows the existing binding defined at <interactive>:1:1 λ:3> let x = 1 <interactive>:3:5: warning: [-Wname-shadowing] This binding for ‘x’ shadows the existing binding defined at <interactive>:2:1 λ:4> x <- return () <interactive>:4:1: warning: [-Wname-shadowing] This binding for ‘x’ shadows the existing binding defined at <interactive>:3:5 }}} If we merge it we should add a test and close this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11606#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11606: name shadowing warnings don't trigger on standalone declarations in ghci -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: (none) Type: bug | Status: patch Priority: high | Milestone: 8.4.1 Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #16096 | Differential Rev(s): MR:97 Wiki Page: | -------------------------------------+------------------------------------- Changes (by osa1): * status: new => patch * differential: => MR:97 Comment: The Phab patch is migrated to https://gitlab.haskell.org/ghc/ghc/merge_requests/97. I also added a test for this ticket there so I'm officially making it a fix for this ticket. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11606#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11606: name shadowing warnings don't trigger on standalone declarations in ghci -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: (none) Type: bug | Status: merge Priority: high | Milestone: 8.4.1 Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #16096 | Differential Rev(s): MR:97 Wiki Page: | -------------------------------------+------------------------------------- Changes (by osa1): * status: patch => merge Comment: Fixed with a34ee6154. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11606#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11606: name shadowing warnings don't trigger on standalone declarations in ghci -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: (none) Type: bug | Status: closed Priority: high | Milestone: 8.4.1 Component: GHCi | Version: 7.10.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #16096 | Differential Rev(s): MR:97 Wiki Page: | -------------------------------------+------------------------------------- Changes (by osa1): * status: merge => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11606#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11606: name shadowing warnings don't trigger on standalone declarations in ghci -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: (none) Type: bug | Status: closed Priority: high | Milestone: 8.8.1 Component: GHCi | Version: 7.10.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | ghci/scripts/T11606 Blocked By: | Blocking: Related Tickets: #16096 | Differential Rev(s): MR:97 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * testcase: => ghci/scripts/T11606 * milestone: 8.4.1 => 8.8.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11606#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11606: name shadowing warnings don't trigger on standalone declarations in ghci
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner: (none)
Type: bug | Status: closed
Priority: high | Milestone: 8.8.1
Component: GHCi | Version: 7.10.3
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
| ghci/scripts/T11606
Blocked By: | Blocking:
Related Tickets: #16096 | Differential Rev(s): MR:97
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ömer Sinan Ağacan
participants (1)
-
GHC