Implement NoFieldSelectors
Thank you for your contribution to GHC!
Please take a few moments to verify that your commits fulfill the following:
-
are either individually buildable or squashed -
have commit messages which describe what they do (referring to Notes and tickets using #NNNN
syntax when appropriate) -
have added source comments describing your change. For larger changes you likely should add a Note and cross-reference it from the relevant places. -
add a testcase to the testsuite. -
This MR implements the NoFieldSelectors proposal.
Summary of the changes
(Items with bold texts are the key parts of the implementation.)
- A new language extension,
FieldSelectors
, is added and enabled by default. -
NoFieldSelectors
negatesFieldSelectors
. -
We added a new field in
FieldLabel
indicating whetherFieldSelectors
is enabled in the definition. As a result, we had to update the use sites ofFieldLabel
. - Previously, whether
DuplicateRecordFields
is in effect is represented by Bool; we replaced it by an explicit datatype instead. -
lookupOccRn_overloaded
has been renamed tolookupOccRn_overloaded_expr
.- It is used to look up variables in expressions.
-
Selector functions created with
NoFieldSelectors
are hidden from this function.
-
lookupGlobalOccRn_overloaded
has been renamed tolookupGlobalOccRn_overloaded_pat
.- It is used to find field names in record patterns, updates, and constructions.
-
It can find selector functions with
NoFieldSelectors
.
- Created a new datatype
LookupOccRnOverloadedResult
in place ofEither Name [Name]
- Fixed the bug #18729 (closed) preventing it work on GHCi
Edited by Adam Gundry