Skip to content

Implement NoFieldSelectors extension

Adam Gundry requested to merge wip/amg/fieldselectors into master

This implements the NoFieldSelectors ghc-proposal (fixes #5972 (closed)), adding an extension to disable the generation of selector functions corresponding to record fields. When this extension is enabled, record field selectors are not accessible as functions, but users are still able to use them for record construction, pattern matching and updates. See Note [NoFieldSelectors] in GHC.Rename.Env for details.

Along the way, this fixes the use of non-imported DuplicateRecordFields in GHCi with -fimplicit-import-qualified (fixes #18729 (closed)), and slightly liberalises DisambiguateRecordFields for updates (fixes #18999 (closed)).

Many thanks to @reactormonk and @fumieval for originally working on this. This MR is based on !4017 (closed) but I thought it best to open a new MR as I've revised it quite a bit both to incorporate !4467 (closed) and to tidy up some of the renamer logic. @reactormonk @fumieval please do feel free to review the further changes I've made.

Edited by Adam Gundry

Merge request reports