Implement DuplicateRecordFields
authorAdam Gundry <adam@well-typed.com>
Fri, 16 Oct 2015 15:08:31 +0000 (16:08 +0100)
committerAdam Gundry <adam@well-typed.com>
Fri, 16 Oct 2015 15:27:53 +0000 (16:27 +0100)
commitb1884b0e62f62e3c0859515c4137124ab0c9560e
tree9037ed61aeaf16b243c4b8542e3ef11f4abd7ee7
parent808bbdf08058785ae5bc59b5b4f2b04951d4cbbf
Implement DuplicateRecordFields

This implements DuplicateRecordFields, the first part of the
OverloadedRecordFields extension, as described at
https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/DuplicateRecordFields

This includes fairly wide-ranging changes in order to allow multiple
records within the same module to use the same field names.  Note that
it does *not* allow record selector functions to be used if they are
ambiguous, and it does not have any form of type-based disambiguation
for selectors (but it does for updates). Subsequent parts will make
overloading selectors possible using orthogonal extensions, as
described on the wiki pages.  This part touches quite a lot of the
codebase, and requires changes to several GHC API datatypes in order
to distinguish between field labels (which may be overloaded) and
selector function names (which are always unique).

The Haddock submodule has been adapted to compile with the GHC API
changes, but it will need further work to properly support modules
that use the DuplicateRecordFields extension.

Test Plan: New tests added in testsuite/tests/overloadedrecflds; these
will be extended once the other parts are implemented.

Reviewers: goldfire, bgamari, simonpj, austin

Subscribers: sjcjoosten, haggholm, mpickering, bgamari, tibbe, thomie,
goldfire

Differential Revision: https://phabricator.haskell.org/D761
113 files changed:
compiler/basicTypes/Avail.hs
compiler/basicTypes/ConLike.hs
compiler/basicTypes/DataCon.hs
compiler/basicTypes/DataCon.hs-boot
compiler/basicTypes/FieldLabel.hs [new file with mode: 0644]
compiler/basicTypes/Id.hs
compiler/basicTypes/OccName.hs
compiler/basicTypes/RdrName.hs
compiler/basicTypes/SrcLoc.hs
compiler/deSugar/Check.hs
compiler/deSugar/Coverage.hs
compiler/deSugar/DsExpr.hs
compiler/deSugar/DsMeta.hs
compiler/deSugar/DsMonad.hs
compiler/deSugar/MatchCon.hs
compiler/ghc.cabal.in
compiler/ghc.mk
compiler/hsSyn/Convert.hs
compiler/hsSyn/HsDecls.hs
compiler/hsSyn/HsExpr.hs
compiler/hsSyn/HsImpExp.hs
compiler/hsSyn/HsPat.hs
compiler/hsSyn/HsTypes.hs
compiler/hsSyn/HsUtils.hs
compiler/hsSyn/PlaceHolder.hs
compiler/iface/BuildTyCl.hs
compiler/iface/IfaceSyn.hs
compiler/iface/LoadIface.hs
compiler/iface/MkIface.hs
compiler/iface/TcIface.hs
compiler/main/DynFlags.hs
compiler/main/GHC.hs
compiler/main/HscTypes.hs
compiler/parser/Parser.y
compiler/parser/RdrHsSyn.hs
compiler/prelude/PrelInfo.hs
compiler/rename/RnEnv.hs
compiler/rename/RnExpr.hs
compiler/rename/RnNames.hs
compiler/rename/RnPat.hs
compiler/rename/RnSource.hs
compiler/rename/RnTypes.hs
compiler/typecheck/Inst.hs
compiler/typecheck/TcEnv.hs
compiler/typecheck/TcExpr.hs
compiler/typecheck/TcGenDeriv.hs
compiler/typecheck/TcGenGenerics.hs
compiler/typecheck/TcHsSyn.hs
compiler/typecheck/TcPat.hs
compiler/typecheck/TcRnDriver.hs
compiler/typecheck/TcRnMonad.hs
compiler/typecheck/TcRnTypes.hs
compiler/typecheck/TcSplice.hs
compiler/typecheck/TcTyClsDecls.hs
compiler/types/TyCon.hs
compiler/types/TyCon.hs-boot
compiler/utils/FastStringEnv.hs [new file with mode: 0644]
testsuite/tests/driver/T4437.hs
testsuite/tests/module/mod176.stderr
testsuite/tests/overloadedrecflds/Makefile [new file with mode: 0644]
testsuite/tests/overloadedrecflds/ghci/Makefile [new file with mode: 0644]
testsuite/tests/overloadedrecflds/ghci/all.T [new file with mode: 0644]
testsuite/tests/overloadedrecflds/ghci/overloadedrecfldsghci01.script [new file with mode: 0644]
testsuite/tests/overloadedrecflds/ghci/overloadedrecfldsghci01.stdout [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/Makefile [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/OverloadedRecFldsFail04_A.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/OverloadedRecFldsFail06_A.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/OverloadedRecFldsFail10_A.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/OverloadedRecFldsFail10_B.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/OverloadedRecFldsFail10_C.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/OverloadedRecFldsFail12_A.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/all.T [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail01.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail01.stderr [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail02.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail02.stderr [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail03.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail03.stderr [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail04.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail04.stderr [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail05.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail05.stderr [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail07.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail07.stderr [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail08.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail08.stderr [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail09.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail09.stderr [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail10.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail10.stderr [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.stderr [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail12.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail12.stderr [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_run/Makefile [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_run/OverloadedRecFldsRun02_A.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_run/all.T [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_run/overloadedrecfldsrun01.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_run/overloadedrecfldsrun01.stdout [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_run/overloadedrecfldsrun02.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_run/overloadedrecfldsrun02.stdout [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_run/overloadedrecfldsrun03.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_run/overloadedrecfldsrun03.stdout [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_run/overloadedrecfldsrun04.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_run/overloadedrecfldsrun04.stdout [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_run/overloadedrecfldsrun05.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_run/overloadedrecfldsrun05.stdout [new file with mode: 0644]
testsuite/tests/rename/should_compile/T7145b.stderr
testsuite/tests/rename/should_fail/T5892a.stderr
utils/ghctags/Main.hs
utils/haddock