diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2017-05-25 09:59:29 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2017-05-25 10:09:41 +0100 |
commit | c9977385dca9536f18374242f713b1048a38dec5 (patch) | |
tree | aaa94d742ea58060bf0b4f9fde713a896abaf735 /testsuite/tests/patsyn | |
parent | 10131947b212770c837035f042a11c024cf0ec67 (diff) | |
download | haskell-c9977385dca9536f18374242f713b1048a38dec5.tar.gz |
Pattern synonyms and higher rank types
This patch fixes two separate bugs which contributed to making
Trac #13752 go wrong
1. We need to use tcSubType, not tcUnify,
in tcCheckPatSynDecl.tc_arg.
Reason: Note [Pattern synonyms and higher rank types]
2. TcUnify.tc_sub_type had a special case designed to improve error
messages; see Note [Don't skolemise unnecessarily]. But the
special case was too liberal, and ended up using unification
(which led to rejecting the program) when it should instead taken
the normal path (which accepts the program).
I fixed this by making the test more conservative.
Diffstat (limited to 'testsuite/tests/patsyn')
-rw-r--r-- | testsuite/tests/patsyn/should_compile/T13752.hs | 9 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_compile/T13752a.hs | 8 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_compile/all.T | 2 |
3 files changed, 19 insertions, 0 deletions
diff --git a/testsuite/tests/patsyn/should_compile/T13752.hs b/testsuite/tests/patsyn/should_compile/T13752.hs new file mode 100644 index 0000000000..f9ff606ee7 --- /dev/null +++ b/testsuite/tests/patsyn/should_compile/T13752.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE TypeFamilies, ConstraintKinds, PatternSynonyms, RankNTypes #-} + +module T13752 where + +newtype Arrange = Arrange {getArrange :: [Int] -> [Int]} + +pattern Heh :: (c ~ ((~) Int)) => (forall a. c a => [a] -> [a]) -> Arrange +-- pattern Heh :: (forall a. (Int ~ a) => [a] -> [a]) -> Arrange +pattern Heh f <- Arrange f diff --git a/testsuite/tests/patsyn/should_compile/T13752a.hs b/testsuite/tests/patsyn/should_compile/T13752a.hs new file mode 100644 index 0000000000..2c417f9fed --- /dev/null +++ b/testsuite/tests/patsyn/should_compile/T13752a.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE PatternSynonyms, RankNTypes #-} + +module T13752a where + +data T = MkT (forall a. a->a) + +pattern P :: (Int -> Int) -> T +pattern P x <- MkT x diff --git a/testsuite/tests/patsyn/should_compile/all.T b/testsuite/tests/patsyn/should_compile/all.T index fa8a3d8455..30319c7050 100644 --- a/testsuite/tests/patsyn/should_compile/all.T +++ b/testsuite/tests/patsyn/should_compile/all.T @@ -68,3 +68,5 @@ test('T13441', normal, compile, ['']) test('T13441a', normal, compile, ['']) test('T13441b', normal, compile_fail, ['']) test('T13454', normal, compile, ['']) +test('T13752', normal, compile, ['']) +test('T13752a', normal, compile, ['']) |