[GHC] #11103: DuplicateRecordFields + TemplateHaskell
#11103: DuplicateRecordFields + TemplateHaskell -------------------------------------+------------------------------------- Reporter: adamgundry | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Template | Version: 7.11 Haskell | 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 [wiki:Records/OverloadedRecordFields/DuplicateRecordFields DuplicateRecordFields] extension works by mangling the Names of field selector functions, and treating fields specially in the renamer. Thus if you define {{{ data T = MkT { foo :: Int } }}} then GHC will actually generate a selector called `$sel:foo:MkT`, but will resolve `foo` to refer to this selector. In general we want this name-mangling to be internal only, but at the moment it is visible when using Template Haskell, because the TH AST doesn't have a way to represent the distinction between the selector name and the field label. For example, if you reify `''T` above and then pretty-print it you will currently get {{{ data T = MkT { $sel:foo:MkT :: Int } }}} which is obviously bad. I'm not sure how best to address this. We could represent the name as `mkNameG_v pkg mod "foo"`, which will look okay when inspected, but if it is subsequently reified it might be ambiguous. Should we add a new `NameFlavour`? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11103> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11103: DuplicateRecordFields + TemplateHaskell -------------------------------------+------------------------------------- Reporter: adamgundry | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1586 Wiki Page: | -------------------------------------+------------------------------------- Changes (by adamgundry): * status: new => patch * differential: => Phab:D1586 Comment: I've proposed a simple change to how `reify` works for duplicate record fields, which will mean that normal uses of TH continue to work, but that re-`reify`ing the name of a field will fail. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11103#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11103: DuplicateRecordFields + TemplateHaskell -------------------------------------+------------------------------------- Reporter: adamgundry | Owner: adamgundry Type: bug | Status: patch Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1586 Wiki Page: | -------------------------------------+------------------------------------- Changes (by adamgundry): * owner: => adamgundry -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11103#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11103: DuplicateRecordFields + TemplateHaskell -------------------------------------+------------------------------------- Reporter: adamgundry | Owner: adamgundry Type: bug | Status: patch Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1586 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"4b161c93dba774cc8051cf40a2024ad86f3259f2/ghc" 4b161c93/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="4b161c93dba774cc8051cf40a2024ad86f3259f2" Reify DuplicateRecordFields by label, rather than by selector See `Note [Reifying field labels]` in `TcSplice`. This makes typical uses of TH work better with `DuplicateRecordFields`. If `reify` is called on the `Name` of a field label produced by the output of a previous `reify`, and there are multiple fields with that label defined in the same module, it may fail with an ambiguity error. Test Plan: Added tests, and manually tested that this makes Aeson's `deriveJSON` avoid the `$sel:` prefixes. Reviewers: simonpj, goldfire, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1586 GHC Trac Issues: #11103 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11103#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11103: DuplicateRecordFields + TemplateHaskell -------------------------------------+------------------------------------- Reporter: adamgundry | Owner: adamgundry Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 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): Phab:D1586 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11103#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11103: DuplicateRecordFields + TemplateHaskell -------------------------------------+------------------------------------- Reporter: adamgundry | Owner: adamgundry Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 Resolution: fixed | Keywords: ORF Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1586 Wiki Page: | -------------------------------------+------------------------------------- Changes (by adamgundry): * keywords: => ORF -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11103#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC