diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2022-05-06 11:01:01 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2022-06-14 12:11:09 -0400 |
commit | c96b48891404738ba50d0b1fb6daa7c036d8ea10 (patch) | |
tree | 12930a56ff2824c141570968bf9f98cbe9dc2122 /testsuite | |
parent | dc790cc292a7f4a3e631838281832f5723945945 (diff) | |
download | haskell-c96b48891404738ba50d0b1fb6daa7c036d8ea10.tar.gz |
Check for uninferrable variables in tcInferPatSynDecl
This fixes #21479
See Note [Unquantified tyvars in a pattern synonym]
While doing this, I found that some error messages pointed at the
pattern synonym /name/, rather than the /declaration/ so I widened the
SrcSpan to encompass the declaration.
(cherry picked from commit bdc99cc22c903d15eb7f4cd8da4b37d307179808)
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/linear/should_fail/LinearPatSyn2.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/T11667.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/T14507.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/T14552.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/T15685.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/T21479.hs | 13 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/T21479.stderr | 5 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/all.T | 1 |
8 files changed, 24 insertions, 5 deletions
diff --git a/testsuite/tests/linear/should_fail/LinearPatSyn2.stderr b/testsuite/tests/linear/should_fail/LinearPatSyn2.stderr index 1360983907..78b3ee52f6 100644 --- a/testsuite/tests/linear/should_fail/LinearPatSyn2.stderr +++ b/testsuite/tests/linear/should_fail/LinearPatSyn2.stderr @@ -1,5 +1,5 @@ -LinearPatSyn2.hs:6:9: error: +LinearPatSyn2.hs:6:1: error: • Pattern synonyms do not support linear fields (GHC #18806): x %1 -> Maybe x • In the declaration for pattern synonym ‘J’ diff --git a/testsuite/tests/patsyn/should_fail/T11667.stderr b/testsuite/tests/patsyn/should_fail/T11667.stderr index f4dafc0f28..e08299b235 100644 --- a/testsuite/tests/patsyn/should_fail/T11667.stderr +++ b/testsuite/tests/patsyn/should_fail/T11667.stderr @@ -3,7 +3,7 @@ T11667.hs:12:22: error: • Could not deduce (Num a) arising from the literal ‘42’ from the context: Eq a bound by the signature for pattern synonym ‘Pat1’ - at T11667.hs:12:9-12 + at T11667.hs:12:1-23 Possible fix: add (Num a) to the "required" context of the signature for pattern synonym ‘Pat1’ diff --git a/testsuite/tests/patsyn/should_fail/T14507.stderr b/testsuite/tests/patsyn/should_fail/T14507.stderr index beeb4de685..d3dfa0a04f 100644 --- a/testsuite/tests/patsyn/should_fail/T14507.stderr +++ b/testsuite/tests/patsyn/should_fail/T14507.stderr @@ -1,5 +1,5 @@ -T14507.hs:21:9: error: +T14507.hs:21:1: error: • Iceland Jack! Iceland Jack! Stop torturing me! Pattern-bound variable x :: TypeRep a has a type that mentions pattern-bound coercion: co diff --git a/testsuite/tests/patsyn/should_fail/T14552.stderr b/testsuite/tests/patsyn/should_fail/T14552.stderr index 34ee266cdd..92c1adb57b 100644 --- a/testsuite/tests/patsyn/should_fail/T14552.stderr +++ b/testsuite/tests/patsyn/should_fail/T14552.stderr @@ -1,5 +1,5 @@ -T14552.hs:22:9: error: +T14552.hs:22:1: error: • Cannot generalise type; skolem ‘k’ would escape its scope if I tried to quantify (t0 :: k) in this type: forall k (w :: k --> *). Exp a0 (F @k @(*) w t0) diff --git a/testsuite/tests/patsyn/should_fail/T15685.stderr b/testsuite/tests/patsyn/should_fail/T15685.stderr index afc6d45de4..204260a9e4 100644 --- a/testsuite/tests/patsyn/should_fail/T15685.stderr +++ b/testsuite/tests/patsyn/should_fail/T15685.stderr @@ -9,7 +9,7 @@ T15685.hs:13:24: error: at T15685.hs:13:19-26 ‘k’ is a rigid type variable bound by the inferred type of HereNil :: NS f as - at T15685.hs:13:9-15 + at T15685.hs:13:1-26 • In the pattern: Nil In the pattern: Here Nil In the declaration for pattern synonym ‘HereNil’ diff --git a/testsuite/tests/patsyn/should_fail/T21479.hs b/testsuite/tests/patsyn/should_fail/T21479.hs new file mode 100644 index 0000000000..889e811e88 --- /dev/null +++ b/testsuite/tests/patsyn/should_fail/T21479.hs @@ -0,0 +1,13 @@ +{-# Language PatternSynonyms #-} +{-# Language ViewPatterns #-} +{-# Language GADTs #-} + +module T21479 where + +data T a where + MkT :: T Int + +foo :: () -> T a +foo = foo + +pattern T1 <- (foo -> MkT)
\ No newline at end of file diff --git a/testsuite/tests/patsyn/should_fail/T21479.stderr b/testsuite/tests/patsyn/should_fail/T21479.stderr new file mode 100644 index 0000000000..07601492a8 --- /dev/null +++ b/testsuite/tests/patsyn/should_fail/T21479.stderr @@ -0,0 +1,5 @@ + +T21479.hs:13:1: error: + • Uninferrable type variable a0 in + the provided context: (a0 :: *) ~ (Int :: *) + • In the declaration for pattern synonym ‘T1’ diff --git a/testsuite/tests/patsyn/should_fail/all.T b/testsuite/tests/patsyn/should_fail/all.T index 8993e5c4bf..2db852a35b 100644 --- a/testsuite/tests/patsyn/should_fail/all.T +++ b/testsuite/tests/patsyn/should_fail/all.T @@ -48,3 +48,4 @@ test('T15694', normal, compile_fail, ['']) test('T16900', normal, compile_fail, ['-fdiagnostics-show-caret']) test('T14552', normal, compile_fail, ['']) test('T18856', normal, compile_fail, ['-fdiagnostics-show-caret']) +test('T21479', normal, compile_fail, ['']) |