Provide a better error message for unpromotable data constructor contexts
authorRyan Scott <ryan.gl.scott@gmail.com>
Sun, 17 Jun 2018 16:28:23 +0000 (12:28 -0400)
committerBen Gamari <ben@smart-cactus.org>
Sun, 17 Jun 2018 16:42:56 +0000 (12:42 -0400)
commitc63754118cf6c3d0947d0c611f1db39c78acf1b7
tree07572deedcf1a73fda2cd540426dcf14666587a4
parent793902e6891c30150fd3ac1e0e471269a4766780
Provide a better error message for unpromotable data constructor contexts

Trac #14845 brought to light a corner case where a data
constructor could not be promoted (even with `-XTypeInType`) due to
an unpromotable constraint in its context. However, the error message
was less than helpful, so this patch adds an additional check to
`tcTyVar` catch unpromotable data constructors like these //before//
they're promoted, and to give a sensible error message in such cases.

Test Plan: make test TEST="T13895 T14845"

Reviewers: simonpj, goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #13895, #14845

Differential Revision: https://phabricator.haskell.org/D4728
16 files changed:
compiler/typecheck/Inst.hs
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcRnTypes.hs
docs/users_guide/glasgow_exts.rst
testsuite/tests/dependent/should_compile/T14845_compile.hs [new file with mode: 0644]
testsuite/tests/dependent/should_compile/all.T
testsuite/tests/dependent/should_fail/PromotedClass.stderr
testsuite/tests/dependent/should_fail/T13895.hs [new file with mode: 0644]
testsuite/tests/dependent/should_fail/T13895.stderr [new file with mode: 0644]
testsuite/tests/dependent/should_fail/T14845.stderr [new file with mode: 0644]
testsuite/tests/dependent/should_fail/T14845_fail1.hs [new file with mode: 0644]
testsuite/tests/dependent/should_fail/T14845_fail1.stderr [new file with mode: 0644]
testsuite/tests/dependent/should_fail/T14845_fail2.hs [new file with mode: 0644]
testsuite/tests/dependent/should_fail/T14845_fail2.stderr [new file with mode: 0644]
testsuite/tests/dependent/should_fail/T15215.stderr
testsuite/tests/dependent/should_fail/all.T