summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2019-07-30 10:44:33 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-08-02 08:14:47 -0400
commit1b9d32b8b8d55335bed7fb3677054327c6072768 (patch)
tree36a22b007672e910a7ef89135e45f0c00ac2ddea /testsuite
parent9552114006ea81e379228706caf30cbe3323e1d2 (diff)
downloadhaskell-1b9d32b8b8d55335bed7fb3677054327c6072768.tar.gz
Rip out 9-year-old pattern variable hack (#17007)
GHC had an ad hoc validity check in place to rule out pattern variables bound by type synonyms, such as in the following example: ```hs type ItemColID a b = Int -- Discards a,b get :: ItemColID a b -> ItemColID a b get (x :: ItemColID a b) = x :: ItemColID a b ``` This hack is wholly unnecessary nowadays, since OutsideIn(X) is more than capable of instantiating `a` and `b` to `Any`. In light of this, let's rip out this validity check. Fixes #17007.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/typecheck/should_compile/T17007.hs13
-rw-r--r--testsuite/tests/typecheck/should_compile/all.T1
-rw-r--r--testsuite/tests/typecheck/should_fail/T3406.stderr18
3 files changed, 23 insertions, 9 deletions
diff --git a/testsuite/tests/typecheck/should_compile/T17007.hs b/testsuite/tests/typecheck/should_compile/T17007.hs
new file mode 100644
index 0000000000..21b7639dd0
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T17007.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeFamilies #-}
+module T17007 where
+
+type ItemColID a b = Int -- Discards a,b
+
+get :: ItemColID a b -> ItemColID a b
+get (x :: ItemColID a b) = x :: ItemColID a b
+
+type family ItemColID' a b where ItemColID' a b = Int -- Discards a,b
+
+get' :: ItemColID' a b -> ItemColID' a b
+get' (x :: ItemColID' a b) = x :: ItemColID' a b
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index 9e9d48659d..e393fe41c7 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -685,3 +685,4 @@ test('UnliftedNewtypesLPFamily', normal, compile, [''])
test('UnliftedNewtypesDifficultUnification', normal, compile, [''])
test('T16832', normal, ghci_script, ['T16832.script'])
test('T16946', normal, compile, [''])
+test('T17007', normal, compile, [''])
diff --git a/testsuite/tests/typecheck/should_fail/T3406.stderr b/testsuite/tests/typecheck/should_fail/T3406.stderr
index 4525bba5d6..69834d15f6 100644
--- a/testsuite/tests/typecheck/should_fail/T3406.stderr
+++ b/testsuite/tests/typecheck/should_fail/T3406.stderr
@@ -1,10 +1,10 @@
-T3406.hs:11:6:
- The type variables ‘a, b’
- should be bound by the pattern signature ‘ItemColID a b’
- but are actually discarded by a type synonym
- To fix this, expand the type synonym
- [Note: I hope to lift this restriction in due course]
- In the pattern: x :: ItemColID a b
- In an equation for ‘get’:
- get (x :: ItemColID a b) = x :: ItemColID a b
+T3406.hs:11:28: error:
+ • Couldn't match type ‘Int’ with ‘a -> ItemColID a b’
+ Expected type: a -> ItemColID a b
+ Actual type: ItemColID a1 b1
+ • In the expression: x :: ItemColID a b
+ In an equation for ‘get’:
+ get (x :: ItemColID a b) = x :: ItemColID a b
+ • Relevant bindings include
+ get :: ItemColID a b -> a -> ItemColID a b (bound at T3406.hs:11:1)