Implement NoFieldSelectors extension (ghc-proposals 160)
Fixes #5972. This adds an extension NoFieldSelectors 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. Defining the same field multiple times requires the DuplicateRecordFields extension to be enabled, even when NoFieldSelectors is in use. Along the way, this fixes the use of non-imported DuplicateRecordFields in GHCi with -fimplicit-import-qualified (fixes #18729). Moreover, it extends DisambiguateRecordFields to ignore non-fields when looking up fields in record updates (fixes #18999), as described by Note [DisambiguateRecordFields for updates]. Co-authored-by:Simon Hafner <hafnersimon@gmail.com> Co-authored-by:
Fumiaki Kinoshita <fumiexcel@gmail.com>
Showing
- compiler/GHC/Driver/Session.hs 16 additions, 0 deletionscompiler/GHC/Driver/Session.hs
- compiler/GHC/Iface/Ext/Ast.hs 4 additions, 4 deletionscompiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Rename.hs 3 additions, 3 deletionscompiler/GHC/Iface/Rename.hs
- compiler/GHC/Rename/Env.hs 319 additions, 78 deletionscompiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Expr.hs 12 additions, 10 deletionscompiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Module.hs 6 additions, 5 deletionscompiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs 82 additions, 44 deletionscompiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Pat.hs 16 additions, 31 deletionscompiler/GHC/Rename/Pat.hs
- compiler/GHC/Rename/Unbound.hs 22 additions, 1 deletioncompiler/GHC/Rename/Unbound.hs
- compiler/GHC/Rename/Utils.hs 48 additions, 5 deletionscompiler/GHC/Rename/Utils.hs
- compiler/GHC/Tc/Gen/Export.hs 1 addition, 1 deletioncompiler/GHC/Tc/Gen/Export.hs
- compiler/GHC/Tc/Gen/Expr.hs 1 addition, 2 deletionscompiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Head.hs 13 additions, 5 deletionscompiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/Splice.hs 4 additions, 14 deletionscompiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/TyCl/PatSyn.hs 6 additions, 4 deletionscompiler/GHC/Tc/TyCl/PatSyn.hs
- compiler/GHC/Tc/TyCl/Utils.hs 25 additions, 2 deletionscompiler/GHC/Tc/TyCl/Utils.hs
- compiler/GHC/Types/Avail.hs 19 additions, 19 deletionscompiler/GHC/Types/Avail.hs
- compiler/GHC/Types/FieldLabel.hs 80 additions, 19 deletionscompiler/GHC/Types/FieldLabel.hs
- compiler/GHC/Types/Name/Reader.hs 31 additions, 8 deletionscompiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Types/Name/Shape.hs 2 additions, 2 deletionscompiler/GHC/Types/Name/Shape.hs
Loading
Please register or sign in to comment