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 #NNNNsyntax 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. -
NoFieldSelectorsnegatesFieldSelectors. -
We added a new field in
FieldLabelindicating whetherFieldSelectorsis enabled in the definition. As a result, we had to update the use sites ofFieldLabel. - Previously, whether
DuplicateRecordFieldsis in effect is represented by Bool; we replaced it by an explicit datatype instead. -
lookupOccRn_overloadedhas been renamed tolookupOccRn_overloaded_expr.- It is used to look up variables in expressions.
-
Selector functions created with
NoFieldSelectorsare hidden from this function.
-
lookupGlobalOccRn_overloadedhas 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
LookupOccRnOverloadedResultin place ofEither Name [Name] - Fixed the bug #18729 (closed) preventing it work on GHCi
Edited by Adam Gundry