summaryrefslogtreecommitdiff
path: root/testsuite/tests/boxy
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2016-09-25 15:50:18 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2016-09-30 12:53:27 +0100
commitb612da667fe8fa5277fc78e972a86d4b35f98364 (patch)
tree814c66b0dfb9e218d25f21f1d84617088c151987 /testsuite/tests/boxy
parent3012c431e466c55fccff0dd916987a9478cb1ae3 (diff)
downloadhaskell-b612da667fe8fa5277fc78e972a86d4b35f98364.tar.gz
Fix impredicativity (again)
This patch fixes Trac #12616. Dignosis. In TcUnify.tc_sub_type_ds we were going to some trouble to support co- and contra-variance even for impredicative types. With -XImpredicativeTYpes, this allowed a unification variable to be unified with a polytype (probably wrongly) and that caused later trouble in the constraint solver, where -XImpredicativeTypes was /not/ on. In effect, -XImpredicativeTypes can't be switched on locally. Why did we want ImpredicativeTypes locally? Because the program generated by GND for a higher-rank method involved impredicative instantation of 'coerce': op = coerce op -- where op has a higher rank type See Note [Newtype-deriving instances] in TcGenDeriv. Cure. 1. It is ghastly to rely on ImpredicativeTypes (a 100% flaky feature) to instantiate coerce polymorphically. Happily we now have Visible Type Application, so I've used that instead which should be solid and reliable. 2. I deleted the code in tc_sub_type_ds that allows the constraint solver to "look through" a unification variable to find a polytype. That used to be essential in the days of ReturnTv, but it's utterly unreliable and should be consigned to the dustbin of history. (We have ExpType now for the essential uses.) Tests involving ImpredicativeTypes are affected, but I'm not worried about them... it's advertised as a feature you can't rely on, and I want to reform it outright.
Diffstat (limited to 'testsuite/tests/boxy')
-rw-r--r--testsuite/tests/boxy/Base1.hs35
-rw-r--r--testsuite/tests/boxy/T2193.hs2
-rw-r--r--testsuite/tests/boxy/all.T4
3 files changed, 23 insertions, 18 deletions
diff --git a/testsuite/tests/boxy/Base1.hs b/testsuite/tests/boxy/Base1.hs
index 88e7e80f17..3f027bb93c 100644
--- a/testsuite/tests/boxy/Base1.hs
+++ b/testsuite/tests/boxy/Base1.hs
@@ -1,30 +1,33 @@
{-# OPTIONS_GHC -XImpredicativeTypes -fno-warn-deprecated-flags #-}
-module Base1 where
--- basic examples of impredicative instantiation of variables
+-- Sept 16: now failing, beause I've furter reduced the scop
+-- of impredicative types
-data MEither a b = MLeft a
- | MRight b
+module Base1 where
+-- basic examples of impredicative instantiation of variables
+
+data MEither a b = MLeft a
+ | MRight b
| MEmpty
-type Sid = forall a. a -> a
+type Sid = forall a. a -> a
--- no need for impredicativity
-test0 = MRight id
+-- no need for impredicativity
+test0 = MRight id
--- requires impredicativity
+-- requires impredicativity
test1 :: Sid -> MEither Sid b
-test1 fid = MLeft fid
+test1 fid = MLeft fid
-test2 :: MEither b Sid -> Maybe (Sid,Sid)
-test2 m = case (test1 id) of
- MLeft x -> case m of
- MRight y -> Just (x,y)
- _ -> Nothing
+test2 :: MEither b Sid -> Maybe (Sid,Sid)
+test2 m = case (test1 id) of
+ MLeft x -> case m of
+ MRight y -> Just (x,y)
+ _ -> Nothing
_ -> Nothing
test3 :: MEither a b -> b
-test3 (MRight x) = x
+test3 (MRight x) = x
-test4 = test3 (test1 id)
+test4 = test3 (test1 id)
diff --git a/testsuite/tests/boxy/T2193.hs b/testsuite/tests/boxy/T2193.hs
index 904a13721c..c36503eae7 100644
--- a/testsuite/tests/boxy/T2193.hs
+++ b/testsuite/tests/boxy/T2193.hs
@@ -1,5 +1,7 @@
{-# OPTIONS_GHC -XImpredicativeTypes -fno-warn-deprecated-flags #-}
+-- Sept 16: now scraping through with -XImpredicateTypes
+
module Main where
data Foo x y = Foo {foo1 :: x, foo2 :: y}
diff --git a/testsuite/tests/boxy/all.T b/testsuite/tests/boxy/all.T
index d2be5e314b..99ab5367f2 100644
--- a/testsuite/tests/boxy/all.T
+++ b/testsuite/tests/boxy/all.T
@@ -1,6 +1,6 @@
# Boxy-type tests
-test('Base1', normal, compile, [''])
+test('Base1', normal, compile_fail, [''])
test('Church1', expect_broken(4295), compile, [''])
test('Church2', expect_broken(1330), compile_fail, [''])
test('PList1', expect_broken(4295), compile, [''])
@@ -8,4 +8,4 @@ test('PList2', expect_broken(4295), compile, [''])
test('SystemF', expect_broken(4295), compile, [''])
test('boxy', expect_broken(4295), compile, [''])
test('Compose', normal, compile, [''])
-test('T2193', expect_broken(4295), compile_and_run, [''])
+test('T2193', normal, compile_and_run, [''])