diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2019-02-14 08:28:43 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2019-02-14 08:40:03 +0000 |
commit | 5c1f268e2744fab2d36e64c163858995451d7095 (patch) | |
tree | cb9b05c9112e6df43d90f28b6e3a252b2a077d46 /compiler/typecheck/TcHsType.hs | |
parent | 682783828275cca5fd8bf5be5b52054c75e0e22c (diff) | |
download | haskell-5c1f268e2744fab2d36e64c163858995451d7095.tar.gz |
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.
Diffstat (limited to 'compiler/typecheck/TcHsType.hs')
-rw-r--r-- | compiler/typecheck/TcHsType.hs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/typecheck/TcHsType.hs b/compiler/typecheck/TcHsType.hs index a6cdd09849..cae0b5bcf2 100644 --- a/compiler/typecheck/TcHsType.hs +++ b/compiler/typecheck/TcHsType.hs @@ -250,6 +250,10 @@ tc_hs_sig_type skol_info hs_sig_type ctxt_kind ; emitResidualTvConstraint skol_info Nothing (kvs ++ spec_tkvs) tc_lvl wanted + -- See Note [Fail fast if there are insoluble kind equalities] + -- in TcSimplify + ; when (insolubleWC wanted) failM + ; return (mkInvForAllTys kvs ty1) } tc_hs_sig_type _ (XHsImplicitBndrs _) _ = panic "tc_hs_sig_type" |