diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2019-03-13 11:15:20 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-03-16 08:08:25 -0400 |
commit | 4927117cd6166a97455d788dbf7433c95441b57a (patch) | |
tree | 07a0e4b2277d0db641254f8b4c0c2fe3f33d588f /testsuite/tests/patsyn | |
parent | 57201bebaeb15c5635ac5ea153b0141b55670199 (diff) | |
download | haskell-4927117cd6166a97455d788dbf7433c95441b57a.tar.gz |
Improve error recovery in the typechecker
Issue #16418 showed that we were carrying on too eagerly after a bogus
type signature was identified (a bad telescope in fact), leading to a
subsequent crash.
This led me in to a maze of twisty little passages in the typechecker's
error recovery, and I ended up doing some refactoring in TcRnMonad.
Some specfifics
* TcRnMonad.try_m is now called attemptM.
* I switched the order of the result pair in tryTc,
to make it consistent with other similar functions.
* The actual exception used in the Tc monad is irrelevant so,
to avoid polluting type signatures, I made tcTryM, a simple
wrapper around tryM, and used it.
The more important changes are in
* TcSimplify.captureTopConstraints, where we should have been calling
simplifyTop rather than reportUnsolved, so that levity defaulting
takes place properly.
* TcUnify.emitResidualTvConstraint, where we need to set the correct
status for a new implication constraint. (Previously we ended up
with an Insoluble constraint wrapped in an Unsolved implication,
which meant that insolubleWC gave the wrong answer.
Diffstat (limited to 'testsuite/tests/patsyn')
-rw-r--r-- | testsuite/tests/patsyn/should_fail/T9161-1.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/T9161-1.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/T9161-2.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/T9161-2.stderr | 2 |
4 files changed, 6 insertions, 2 deletions
diff --git a/testsuite/tests/patsyn/should_fail/T9161-1.hs b/testsuite/tests/patsyn/should_fail/T9161-1.hs index c14eb542cc..32a6f9d6aa 100644 --- a/testsuite/tests/patsyn/should_fail/T9161-1.hs +++ b/testsuite/tests/patsyn/should_fail/T9161-1.hs @@ -1,6 +1,8 @@ {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE DataKinds #-} +module Bug where + pattern PATTERN = () wrongLift :: PATTERN diff --git a/testsuite/tests/patsyn/should_fail/T9161-1.stderr b/testsuite/tests/patsyn/should_fail/T9161-1.stderr index fff6efe286..39faffdaa8 100644 --- a/testsuite/tests/patsyn/should_fail/T9161-1.stderr +++ b/testsuite/tests/patsyn/should_fail/T9161-1.stderr @@ -1,5 +1,5 @@ -T9161-1.hs:6:14: error: +T9161-1.hs:8:14: error: • Pattern synonym ‘PATTERN’ cannot be used here (pattern synonyms cannot be promoted) • In the type signature: wrongLift :: PATTERN diff --git a/testsuite/tests/patsyn/should_fail/T9161-2.hs b/testsuite/tests/patsyn/should_fail/T9161-2.hs index 941d23e35f..ccdfa1ff05 100644 --- a/testsuite/tests/patsyn/should_fail/T9161-2.hs +++ b/testsuite/tests/patsyn/should_fail/T9161-2.hs @@ -1,6 +1,8 @@ {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE DataKinds, KindSignatures, PolyKinds #-} +module Bug where + pattern PATTERN = () data Proxy (tag :: k) (a :: *) diff --git a/testsuite/tests/patsyn/should_fail/T9161-2.stderr b/testsuite/tests/patsyn/should_fail/T9161-2.stderr index cc429313aa..71f7cbe257 100644 --- a/testsuite/tests/patsyn/should_fail/T9161-2.stderr +++ b/testsuite/tests/patsyn/should_fail/T9161-2.stderr @@ -1,5 +1,5 @@ -T9161-2.hs:8:20: error: +T9161-2.hs:10:20: error: • Pattern synonym ‘PATTERN’ cannot be used here (pattern synonyms cannot be promoted) • In the first argument of ‘Proxy’, namely ‘PATTERN’ |