diff options
author | Torsten Schmits <git@tryp.io> | 2023-03-22 13:44:16 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-03-23 09:20:13 -0400 |
commit | e1c8c41d62854553d889403d8ee52d120c26bc66 (patch) | |
tree | 743b77a8ce21c645885a47fb6f454a41d2aada39 /testsuite/tests/typecheck/should_fail | |
parent | 8cb88a5ade9427ca2f26e7f2dbf9defb8fb0ed22 (diff) | |
download | haskell-e1c8c41d62854553d889403d8ee52d120c26bc66.tar.gz |
Add structured error messages for GHC.Tc.TyCl.PatSyn
Tracking ticket: #20117
MR: !10158
This converts uses of `mkTcRnUnknownMessage` to newly added constructors
of `TcRnMessage`.
Diffstat (limited to 'testsuite/tests/typecheck/should_fail')
7 files changed, 33 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/PatSynArity.hs b/testsuite/tests/typecheck/should_fail/PatSynArity.hs new file mode 100644 index 0000000000..4f09dbdcc7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/PatSynArity.hs @@ -0,0 +1,6 @@ +{-# language PatternSynonyms #-} + +module PatSynArity where + +pattern P :: Int -> (Int, Int) +pattern P a b = (a, b) diff --git a/testsuite/tests/typecheck/should_fail/PatSynArity.stderr b/testsuite/tests/typecheck/should_fail/PatSynArity.stderr new file mode 100644 index 0000000000..502255ad4b --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/PatSynArity.stderr @@ -0,0 +1,4 @@ +PatSynArity.hs:6:1: [GHC-18365] + Pattern synonym ‘P’ has two arguments + but its type signature has 1 fewer arrows + In the declaration for pattern synonym ‘P’ diff --git a/testsuite/tests/typecheck/should_fail/PatSynExistential.hs b/testsuite/tests/typecheck/should_fail/PatSynExistential.hs new file mode 100644 index 0000000000..ddfaa2ad16 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/PatSynExistential.hs @@ -0,0 +1,6 @@ +{-# language PatternSynonyms #-} + +module PatSynExistential where + +pattern P :: () => forall x. x -> Maybe x +pattern P <- _ diff --git a/testsuite/tests/typecheck/should_fail/PatSynExistential.stderr b/testsuite/tests/typecheck/should_fail/PatSynExistential.stderr new file mode 100644 index 0000000000..326974dc55 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/PatSynExistential.stderr @@ -0,0 +1,4 @@ +PatSynExistential.hs:6:1: [GHC-33973] + The result type of the signature for ‘P’, namely ‘x -> Maybe x’ + mentions existential type variable ‘x’ + In the declaration for pattern synonym ‘P’ diff --git a/testsuite/tests/typecheck/should_fail/PatSynUnboundVar.hs b/testsuite/tests/typecheck/should_fail/PatSynUnboundVar.hs new file mode 100644 index 0000000000..961713096a --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/PatSynUnboundVar.hs @@ -0,0 +1,6 @@ +{-# language PatternSynonyms #-} + +module PatSynUnboundVar where + +pattern P :: Int -> (Int, Int) +pattern P a = (a, b) diff --git a/testsuite/tests/typecheck/should_fail/PatSynUnboundVar.stderr b/testsuite/tests/typecheck/should_fail/PatSynUnboundVar.stderr new file mode 100644 index 0000000000..f65114aa99 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/PatSynUnboundVar.stderr @@ -0,0 +1,4 @@ +PatSynUnboundVar.hs:6:15: [GHC-28572] + Invalid right-hand side of bidirectional pattern synonym ‘P’: + ‘b’ is not bound by the LHS of the pattern synonym + RHS pattern: (a, b) diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index 94f0cdfa77..209f292737 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -672,3 +672,6 @@ test('T22924a', normal, compile_fail, ['']) test('T22924b', normal, compile_fail, ['']) test('T22940', normal, compile_fail, ['']) test('T19627', normal, compile_fail, ['']) +test('PatSynExistential', normal, compile_fail, ['']) +test('PatSynArity', normal, compile_fail, ['']) +test('PatSynUnboundVar', normal, compile_fail, ['']) |