[GHC] #12229: Narrow the scope of record wildcards notation slightly
#12229: Narrow the scope of record wildcards notation slightly -------------------------------------+------------------------------------- Reporter: simonpj | 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: -------------------------------------+------------------------------------- As fallout from #12130 I narrowed the scope of record-wildcard notation slightly. Here's the commit {{{ commit 2f8cd14fe909a377b3e084a4f2ded83a0e6d44dd Author: Simon Peyton Jones <simonpj@microsoft.com> Date: Thu Jun 23 09:02:00 2016 +0100 Narrow the use of record wildcards slightly In reviewing the fix to Trac #12130 I found the wild-card fill-in code for ".." notation in record constructions hard to understand. It went to great contortions (including the find_tycon code) to allow data T = C { x, y :: Int } f x = C { .. } to expand to f x = C { x = x, y = y } where 'y' is an /imported function/! That seems way over the top for what record wildcards are supposed to do. So I have narrowed the record-wildcard expansion to include only /locally-bound/ variables; i.e. not top level, and certainly not imported. I don't think anyone is using record wildcards in this bizarre way, so I don't expect any fallout. Even if there is, you can easily initialise fields with eponymous but imported values by hand. An intermediate position would be to allow /local/ top-level definitions. But I doubt anyone is doing that either. Let's see if there's any fallout. It's a local change, easy to revert, so I've just gone ahead to save everyone's time. }}} This ticket can be used for any commentary. I've also added a test. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12229> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12229: Narrow the scope of record wildcards notation slightly -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 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): Interestingly, at least some of the things that are now rejected were ALSO rejected before, in a different and more confusing way. Consider {{{ module T12229 where data T = MkT { x, pi :: Float } f x = MkT { .. } -- 'pi' is not initialised, because -- there is no local binding }}} Previously the record-wildcard expansion said "oh, there is one `pi` in scope that isn't a record selector, so fine, let's expand it"; so we got {{{ f x = MkT { x = x, pi = pi } }}} But THEN we got (from 7.10) {{{ T12229 .hs:7:7: Ambiguous occurrence ‘pi’ It could refer to either ‘T12229.pi’, defined at T12229.hs:5:19 or ‘Prelude.pi’, imported from ‘Prelude’ at T12229.hs:3:8-19 (and originally defined in ‘GHC.Float’) }}} which is stupid and confusing. With our new change we get {{{ T12229.hs:7:7: warning: [-Wmissing-fields (in -Wdefault)] Fields of ‘MkT’ not initialised: pi In the expression: MkT {..} In an equation for ‘f’: f x = MkT {..} }}} which is better. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12229#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12229: Narrow the scope of record wildcards notation slightly -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 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 Simon Peyton Jones <simonpj@…>): In [changeset:"dadd8b84a6ba157d54d6f84be247f9dbf06e1611/ghc" dadd8b8/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="dadd8b84a6ba157d54d6f84be247f9dbf06e1611" Test Trac #12229 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12229#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12229: Narrow the scope of record wildcards notation slightly -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: fixed | 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): * status: new => closed * resolution: => fixed * milestone: => 8.2.1 Comment: Closing, as the work is done here. Please leave a comment here or open a new ticket if this change of behavior bites you badly. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12229#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC