From 1b9d32b8b8d55335bed7fb3677054327c6072768 Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Tue, 30 Jul 2019 10:44:33 -0400 Subject: 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. --- testsuite/tests/typecheck/should_compile/T17007.hs | 13 +++++++++++++ testsuite/tests/typecheck/should_compile/all.T | 1 + testsuite/tests/typecheck/should_fail/T3406.stderr | 18 +++++++++--------- 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 testsuite/tests/typecheck/should_compile/T17007.hs (limited to 'testsuite') 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) -- cgit v1.2.1