diff options
author | Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> | 2021-07-27 20:02:14 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-07-29 13:15:09 -0400 |
commit | f4aea1a20d522091286ce429b3aae278ee35d75e (patch) | |
tree | 014ed570cd1e86f3904f696303b4021f8ab7f090 /testsuite | |
parent | 9b916e81234fa71ffde85d17c7e6d96302518cd7 (diff) | |
download | haskell-f4aea1a20d522091286ce429b3aae278ee35d75e.tar.gz |
Reject pattern synonyms with linear types (#18806)
Diffstat (limited to 'testsuite')
5 files changed, 13 insertions, 2 deletions
diff --git a/testsuite/tests/linear/should_fail/LinearPatSyn.hs b/testsuite/tests/linear/should_fail/LinearPatSyn.hs index 3e87bfc078..a874d320d0 100644 --- a/testsuite/tests/linear/should_fail/LinearPatSyn.hs +++ b/testsuite/tests/linear/should_fail/LinearPatSyn.hs @@ -7,7 +7,6 @@ module LinearPatSyn where -- seems to require changes to the desugarer. So currently pattern synonyms are -- disallowed in linear patterns. -pattern P :: b %1 -> a %1 -> (a, b) pattern P y x = (x, y) s :: (a, b) %1 -> (b, a) diff --git a/testsuite/tests/linear/should_fail/LinearPatSyn.stderr b/testsuite/tests/linear/should_fail/LinearPatSyn.stderr index f7c3aab406..95d18396aa 100644 --- a/testsuite/tests/linear/should_fail/LinearPatSyn.stderr +++ b/testsuite/tests/linear/should_fail/LinearPatSyn.stderr @@ -1,5 +1,5 @@ -LinearPatSyn.hs:14:4: error: +LinearPatSyn.hs:13:4: error: • Couldn't match type ‘'Many’ with ‘'One’ arising from a non-linear pattern • In the pattern: P y x diff --git a/testsuite/tests/linear/should_fail/LinearPatSyn2.hs b/testsuite/tests/linear/should_fail/LinearPatSyn2.hs new file mode 100644 index 0000000000..ae1d35ce66 --- /dev/null +++ b/testsuite/tests/linear/should_fail/LinearPatSyn2.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE PatternSynonyms, LinearTypes #-} +module LinearPatSyn2 where + +-- Should be rejected, #18806 +pattern J :: x %1 -> Maybe x +pattern J a = Just a diff --git a/testsuite/tests/linear/should_fail/LinearPatSyn2.stderr b/testsuite/tests/linear/should_fail/LinearPatSyn2.stderr new file mode 100644 index 0000000000..1360983907 --- /dev/null +++ b/testsuite/tests/linear/should_fail/LinearPatSyn2.stderr @@ -0,0 +1,5 @@ + +LinearPatSyn2.hs:6:9: 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/linear/should_fail/all.T b/testsuite/tests/linear/should_fail/all.T index a831011cef..9f8ba14483 100644 --- a/testsuite/tests/linear/should_fail/all.T +++ b/testsuite/tests/linear/should_fail/all.T @@ -17,6 +17,7 @@ test('LinearSeq', normal, compile_fail, ['']) test('LinearViewPattern', normal, compile_fail, ['']) test('LinearConfusedDollar', normal, compile_fail, ['']) test('LinearPatSyn', normal, compile_fail, ['']) +test('LinearPatSyn2', normal, compile_fail, ['']) test('LinearRole', normal, compile_fail, ['']) test('LinearGADTNewtype', normal, compile_fail, ['']) test('LinearPartialSig', normal, compile_fail, ['']) |