Reshuffle levity polymorphism checks.
authorRichard Eisenberg <eir@cis.upenn.edu>
Sat, 17 Dec 2016 23:06:34 +0000 (18:06 -0500)
committerBen Gamari <ben@smart-cactus.org>
Sat, 17 Dec 2016 23:09:37 +0000 (18:09 -0500)
commit8906e7b79a585039712034d9e88ca49f3cea6554
tree7bd338f776d0e08437fd0495ebf0eee098fd54ed
parent6c816c56c674221173e725b5718c8052dda0c8f4
Reshuffle levity polymorphism checks.

Previously, GHC checked for bad levity polymorphism to the left of all
arrows in data constructors. This was wrong, as reported in #12911
(where an example is also shown). The solution is to check each
individual argument for bad levity polymorphism.  Thus the check has
been moved from TcValidity to TcTyClsDecls.

A similar situation exists with pattern synonyms, also fixed here.

This patch also nabs #12819 while I was in town.

Test cases: typecheck/should_compile/T12911, patsyn/should_fail/T12819

Test Plan: ./validate

Reviewers: simonpj, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12819, #12911
14 files changed:
compiler/typecheck/TcSigs.hs
compiler/typecheck/TcTyClsDecls.hs
compiler/typecheck/TcValidity.hs
compiler/types/Type.hs
testsuite/tests/patsyn/should_compile/T8968-2.hs
testsuite/tests/patsyn/should_compile/poly-export2.hs
testsuite/tests/patsyn/should_fail/T11010.hs
testsuite/tests/patsyn/should_fail/T11039.hs
testsuite/tests/patsyn/should_fail/T11039a.hs
testsuite/tests/patsyn/should_fail/T12819.hs [new file with mode: 0644]
testsuite/tests/patsyn/should_fail/T12819.stderr [new file with mode: 0644]
testsuite/tests/patsyn/should_fail/all.T
testsuite/tests/typecheck/should_compile/T12911.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/all.T