[GHC] #12615: Record pattern synonyms cause spurious name shadowing warnings
#12615: Record pattern synonyms cause spurious name shadowing warnings -------------------------------------+------------------------------------- Reporter: gelisam | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 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 example given in the [https://downloads.haskell.org/~ghc/8.0.1/docs/html/users_guide/glasgow_exts.... #record-pattern-synonyms documentation] gives a warning when compiled with `-Wall`: {{{#!hs {-# LANGUAGE PatternSynonyms #-} {-# OPTIONS_GHC -Wall #-} module Test where -- Test.hs:13:24: warning: [-Wname-shadowing] -- This binding for ‘x’ shadows the existing binding -- defined at Test.hs:13:15 -- -- Test.hs:13:27: warning: [-Wname-shadowing] -- This binding for ‘y’ shadows the existing binding -- defined at Test.hs:13:18 pattern Point :: Int -> Int -> (Int, Int) pattern Point{x, y} = (x, y) }}} I don't see anything being shadowed here, so I don't think GHC should produce these warnings. Also, the type signature for that example in the documentation is `pattern Point :: (Int, Int)`, which doesn't compile. Should I file a separate bug for that? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12615> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12615: Record pattern synonyms cause spurious name shadowing warnings -------------------------------------+------------------------------------- Reporter: gelisam | Owner: mpickering Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms 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 mpickering): * keywords: => PatternSynonyms * owner: => mpickering Comment: I will take care of both points mentioned in the ticket. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12615#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12615: Record pattern synonyms cause spurious name shadowing warnings -------------------------------------+------------------------------------- Reporter: gelisam | Owner: mpickering Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms 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 mpickering): This isn't actually a problem with record pattern synonyms per se but something that is exposed by them. You can also trigger the problem with {{{#!hs {-# LANGUAGE NoImplicitPrelude, PatternSynonyms #-} {-# OPTIONS_GHC -Wall #-} module Test where x = () pattern Point2 :: () -> () -> ((), ()) pattern Point2 x y = (x, y) }}} This is because the way checking for shadowed names works assumes that all patterns are introducing binders. Clearly in the case of pattern synonyms this assumption fails so we need to refine this check. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12615#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12615: Record pattern synonyms cause spurious name shadowing warnings -------------------------------------+------------------------------------- Reporter: gelisam | Owner: mpickering Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | patsyn/should_compile/T12615 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2545 Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * status: new => patch * testcase: => patsyn/should_compile/T12615 * differential: => Phab:D2545 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12615#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12615: Record pattern synonyms cause spurious name shadowing warnings -------------------------------------+------------------------------------- Reporter: gelisam | Owner: mpickering Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | patsyn/should_compile/T12615 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2545 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"1851349acd9e73f1c18d68f70d5cf7b46a843cb5/ghc" 1851349a/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="1851349acd9e73f1c18d68f70d5cf7b46a843cb5" Don't warn about name shadowing when renaming the patten in a PatSyn decl Previously the renamer assumed that *any* time we renamed a pattern, the pattern was introducing new binders. This isn't true in pattern synonym declarations where the pattern is used as part of a definition. We add a special case to not warn in this situation. Reviewers: simonpj, austin, bgamari Reviewed By: simonpj Subscribers: simonpj, thomie Differential Revision: https://phabricator.haskell.org/D2545 GHC Trac Issues: #12615 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12615#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12615: Record pattern synonyms cause spurious name shadowing warnings -------------------------------------+------------------------------------- Reporter: gelisam | Owner: mpickering Type: bug | Status: merge Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | patsyn/should_compile/T12615 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2545 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => merge * milestone: => 8.0.2 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12615#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12615: Record pattern synonyms cause spurious name shadowing warnings -------------------------------------+------------------------------------- Reporter: gelisam | Owner: mpickering Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | patsyn/should_compile/T12615 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2545 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-8.0` as 0c2b766d5961562cc8e8603d12399db279ac7e51. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12615#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC