Fail fast in solveLocalEqualities
authorSimon Peyton Jones <simonpj@microsoft.com>
Thu, 14 Feb 2019 08:28:43 +0000 (08:28 +0000)
committerBen Gamari <ben@smart-cactus.org>
Wed, 19 Jun 2019 16:39:50 +0000 (12:39 -0400)
commitce6a492b6d2ec818d6fe57f0892ba0716c1ff9a7
tree47e8dde3753513743db4e8ac1d96049940eea8bc
parent048d4d227dcf1af7019ae658dd71980b9f1406c1
Fail fast in solveLocalEqualities

This patch makes us fail fast in TcSimplify.solveLocalEqualities,
and in TcHsType.tc_hs_sig_type, if there are insoluble constraints.

Previously we ploughed on even if there were insoluble constraints,
leading to a cascade of hard-to-understand type errors. Failing
eagerly is much better; hence a lot of testsuite error message
changes.  Eg if we have
          f :: [Maybe] -> blah
          f xs = e
then trying typecheck 'f x = e' with an utterly bogus type
is just asking for trouble.

I can't quite remember what provoked me to make this change,
but I think the error messages are notably improved, by
removing confusing clutter and focusing on the real error.

(cherry picked from commit 5c1f268e2744fab2d36e64c163858995451d7095)
24 files changed:
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcSimplify.hs
testsuite/tests/dependent/should_fail/DepFail1.stderr
testsuite/tests/ghci/scripts/T15898.stderr
testsuite/tests/indexed-types/should_fail/T13877.stderr
testsuite/tests/partial-sigs/should_fail/T11976.stderr
testsuite/tests/partial-sigs/should_fail/T12634.stderr
testsuite/tests/patsyn/should_fail/T15289.stderr
testsuite/tests/polykinds/T12593.stderr
testsuite/tests/polykinds/T15577.stderr
testsuite/tests/typecheck/should_fail/T11112.stderr
testsuite/tests/typecheck/should_fail/T13819.stderr
testsuite/tests/typecheck/should_fail/T14232.stderr
testsuite/tests/typecheck/should_fail/T3540.stderr
testsuite/tests/typecheck/should_fail/T7778.stderr
testsuite/tests/typecheck/should_fail/T8806.stderr
testsuite/tests/typecheck/should_fail/VtaFail.stderr
testsuite/tests/typecheck/should_fail/tcfail057.stderr
testsuite/tests/typecheck/should_fail/tcfail058.stderr
testsuite/tests/typecheck/should_fail/tcfail063.stderr
testsuite/tests/typecheck/should_fail/tcfail113.stderr
testsuite/tests/typecheck/should_fail/tcfail160.stderr
testsuite/tests/typecheck/should_fail/tcfail161.stderr
testsuite/tests/typecheck/should_fail/tcfail212.stderr