diff options
Diffstat (limited to 'testsuite/tests/patsyn')
-rw-r--r-- | testsuite/tests/patsyn/should_compile/MoreEx.hs | 20 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_compile/T11224b.hs | 17 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_compile/all.T | 3 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/T11010.stderr | 20 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/T9793-fail.stderr | 5 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/as-pattern.stderr | 5 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_run/T11224.hs | 7 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_run/all.T | 3 |
8 files changed, 65 insertions, 15 deletions
diff --git a/testsuite/tests/patsyn/should_compile/MoreEx.hs b/testsuite/tests/patsyn/should_compile/MoreEx.hs new file mode 100644 index 0000000000..ed5e097ee2 --- /dev/null +++ b/testsuite/tests/patsyn/should_compile/MoreEx.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE GADTs, PatternSynonyms #-} + +-- Tests that for unidirectional pattern synonyms +-- the pattern synonym can be more existential +-- (i.e. lose information) wrt the original + +module MoreEx where + +pattern ExCons :: a -> [a] -> [b] +pattern ExCons x xs <- x : xs + +data T where + MkT1 :: ([a] -> Int) -> [a] -> T + MkT2 :: (a -> Int) -> a -> T + +pattern ExT1 :: b -> (b -> Int) -> T +pattern ExT1 x f <- MkT1 f x + +pattern ExT2 :: b -> (c -> Int) -> T +pattern ExT2 x f <- MkT2 f x diff --git a/testsuite/tests/patsyn/should_compile/T11224b.hs b/testsuite/tests/patsyn/should_compile/T11224b.hs new file mode 100644 index 0000000000..89fb764005 --- /dev/null +++ b/testsuite/tests/patsyn/should_compile/T11224b.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE PatternSynonyms, GADTs, RankNTypes #-} + +module T11224b where + +data T b where + MkT :: a -> b -> T b + +-- Should be fine! +-- pattern P :: c -> d -> T d +pattern P :: forall d. forall c. c -> d -> T d +pattern P x y <- MkT x y + + + + + + diff --git a/testsuite/tests/patsyn/should_compile/all.T b/testsuite/tests/patsyn/should_compile/all.T index 3793c0d322..f3d90aceae 100644 --- a/testsuite/tests/patsyn/should_compile/all.T +++ b/testsuite/tests/patsyn/should_compile/all.T @@ -24,6 +24,7 @@ test('T9889', normal, compile, ['']) test('T9867', normal, compile, ['']) test('T9975a', normal, compile_fail, ['']) test('T9975b', normal, compile, ['']) +test('T10426', [expect_broken(10426)], compile, ['']) test('T10747', normal, compile, ['']) test('T10997', [extra_clean(['T10997a.hi', 'T10997a.o'])], multimod_compile, ['T10997', '-v0']) test('T10997_1', [extra_clean(['T10997_1a.hi', 'T10997_1a.o'])], multimod_compile, ['T10997_1', '-v0']) @@ -45,3 +46,5 @@ test('T10897', expect_broken(10897), multi_compile, ['T10897', [ ('T10897a.hs','-c') ,('T10897b.hs', '-c')], '']) test('T9793', normal, compile, ['']) +test('T11224b', normal, compile, ['']) +test('MoreEx', normal, compile, ['']) diff --git a/testsuite/tests/patsyn/should_fail/T11010.stderr b/testsuite/tests/patsyn/should_fail/T11010.stderr index 5f62b1357e..47492cde3a 100644 --- a/testsuite/tests/patsyn/should_fail/T11010.stderr +++ b/testsuite/tests/patsyn/should_fail/T11010.stderr @@ -1,8 +1,14 @@ -T11010.hs:8:1: error: - The 'required' context ‘a ~ Int’ - mentions existential type variable ‘a’ - -T11010.hs:16:1: error: - The 'required' context ‘a ~ Int’ - mentions existential type variable ‘a’ +T11010.hs:9:36: error: + • Couldn't match type ‘a1’ with ‘Int’ + ‘a1’ is a rigid type variable bound by + a pattern with constructor: + Fun :: forall b a. String -> (a -> b) -> Expr a -> Expr b, + in a pattern synonym declaration + at T11010.hs:9:26 + Expected type: a -> b + Actual type: a1 -> b + • In the declaration for pattern synonym ‘IntFun’ + • Relevant bindings include + x :: Expr a1 (bound at T11010.hs:9:36) + f :: a1 -> b (bound at T11010.hs:9:34) diff --git a/testsuite/tests/patsyn/should_fail/T9793-fail.stderr b/testsuite/tests/patsyn/should_fail/T9793-fail.stderr index 62713dcd4c..23122f9ea7 100644 --- a/testsuite/tests/patsyn/should_fail/T9793-fail.stderr +++ b/testsuite/tests/patsyn/should_fail/T9793-fail.stderr @@ -1,4 +1,5 @@ T9793-fail.hs:6:16: error: - Pattern synonym definition cannot contain as-patterns (@) which contain free variables: - x@(y : _) + • Pattern synonym definition cannot contain as-patterns (@) which contain free variables: + x@(y : _) + • In the declaration for pattern synonym ‘P’ diff --git a/testsuite/tests/patsyn/should_fail/as-pattern.stderr b/testsuite/tests/patsyn/should_fail/as-pattern.stderr index caabd47090..00ea6c8091 100644 --- a/testsuite/tests/patsyn/should_fail/as-pattern.stderr +++ b/testsuite/tests/patsyn/should_fail/as-pattern.stderr @@ -1,4 +1,5 @@ as-pattern.hs:4:18: error: - Pattern synonym definition cannot contain as-patterns (@) which contain free variables: - x@(Just y) + • Pattern synonym definition cannot contain as-patterns (@) which contain free variables: + x@(Just y) + • In the declaration for pattern synonym ‘P’ diff --git a/testsuite/tests/patsyn/should_run/T11224.hs b/testsuite/tests/patsyn/should_run/T11224.hs index f834e9b47e..39c744cb5f 100644 --- a/testsuite/tests/patsyn/should_run/T11224.hs +++ b/testsuite/tests/patsyn/should_run/T11224.hs @@ -1,10 +1,10 @@ -{-# LANGUAGE PatternSynonyms , ViewPatterns #-} +{-# LANGUAGE PatternSynonyms, ViewPatterns #-} --- inlining a pattern synonym shouldn't change semantics +module Main where import Text.Read --- pattern PRead :: () => Read a => a -> String +pattern PRead :: Read a => () => a -> String pattern PRead a <- (readMaybe -> Just a) foo :: String -> Int @@ -26,3 +26,4 @@ main = do print $ bar "1" -- 1 print $ bar "[1,2,3]" -- 6 print $ bar "xxx" -- 666 + diff --git a/testsuite/tests/patsyn/should_run/all.T b/testsuite/tests/patsyn/should_run/all.T index c12bfc6cb2..618dd69536 100644 --- a/testsuite/tests/patsyn/should_run/all.T +++ b/testsuite/tests/patsyn/should_run/all.T @@ -12,4 +12,5 @@ test('match-unboxed', normal, compile_and_run, ['']) test('unboxed-wrapper', normal, compile_and_run, ['']) test('records-run', normal, compile_and_run, ['']) test('ghci', just_ghci, ghci_script, ['ghci.script']) -test('T11224', [expect_broken(11224)], compile_and_run, [''])
\ No newline at end of file +test('T11224', [expect_broken(11224)], compile_and_run, ['']) +test('T11224', normal, compile_and_run, ['']) |