Fix infix record field fixity (#11167 and #11173).
authorAdam Gundry <adam@well-typed.com>
Fri, 11 Dec 2015 21:43:26 +0000 (22:43 +0100)
committerBen Gamari <ben@smart-cactus.org>
Fri, 11 Dec 2015 21:44:36 +0000 (22:44 +0100)
commit6e56ac58a6905197412d58e32792a04a63b94d7e
treea204c6ffc3b72c35ad4b44292acdd7a4994d77b0
parentceaf0f4683a3e0ba85ae420956cfc394824e9a38
Fix infix record field fixity (#11167 and #11173).

This extends D1585 with proper support for infix duplicate record
fields.  In particular, it is now possible to declare record fields as
infix in a module for which `DuplicateRecordFields` is enabled, fixity
is looked up correctly and a readable (although unpleasant) error
message is generated if multiple fields with different fixities are in
scope.

As a bonus, `DEPRECATED` and `WARNING` pragmas now work for
duplicate record fields. The pragma applies to all fields with the
given label.

In addition, a couple of minor `DuplicateRecordFields` bugs, which were
pinpointed by the `T11167_ambig` test case, are fixed by this patch:

  - Ambiguous infix fields can now be disambiguated by putting a type
    signature on the first argument

  - Polymorphic type constructor signatures (such as `ContT () IO a` in
    `T11167_ambig`) now work for disambiguation

Parts of this patch are from D1585 authored by @KaneTW.

Test Plan: New tests added.

Reviewers: KaneTW, bgamari, austin

Reviewed By: bgamari

Subscribers: thomie, hvr

Differential Revision: https://phabricator.haskell.org/D1600

GHC Trac Issues: #11167, #11173
22 files changed:
compiler/hsSyn/HsExpr.hs
compiler/hsSyn/HsTypes.hs
compiler/main/HscTypes.hs
compiler/rename/RnEnv.hs
compiler/rename/RnExpr.hs
compiler/rename/RnNames.hs
compiler/rename/RnSource.hs
compiler/typecheck/TcExpr.hs
testsuite/tests/overloadedrecflds/should_compile/T11173.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_compile/T11173a.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_compile/all.T [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/OverloadedRecFldsFail11_A.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity.stderr [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity_A.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/T11167_ambiguous_fixity_B.hs [new file with mode: 0644]
testsuite/tests/overloadedrecflds/should_fail/all.T
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.hs
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.stderr
testsuite/tests/rename/should_compile/T11167.hs [new file with mode: 0644]
testsuite/tests/rename/should_compile/T11167_ambig.hs [new file with mode: 0644]
testsuite/tests/rename/should_compile/all.T