summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorReid Barton <rwbarton@gmail.com>2017-02-05 20:24:06 -0500
committerBen Gamari <ben@smart-cactus.org>2017-02-05 20:26:55 -0500
commit0abe7361249b0b4dc43dc66547451da8916b30bf (patch)
treeca168e80f1b09bf2216aade612fc2c48dd58421d /testsuite/tests
parentfbcef83a3aa130d976a201f2a21c5afc5a43d000 (diff)
downloadhaskell-0abe7361249b0b4dc43dc66547451da8916b30bf.tar.gz
Don't replace type family instances with the same LHS in GHCi (#7102)
This fixes the easy part of #7102 by removing the logic that lets the user replace a type family instance with a new one with the same LHS. As discussed on that ticket, this is unsound in general. Better to have the user redefine the type family from scratch. The example from comment:7 involving loading modules into ghci is not fixed yet; it actually doesn't rely on the instances having the same LHS. This commit adds an expect_broken test for that example as well. Test Plan: T7102a for the fix; T7102 is the test not fixed yet Reviewers: dfeuer, austin, bgamari, goldfire Reviewed By: dfeuer Subscribers: dfeuer, thomie Differential Revision: https://phabricator.haskell.org/D2994
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/ghci/scripts/ghci046.script1
-rw-r--r--testsuite/tests/ghci/scripts/ghci046.stderr5
-rw-r--r--testsuite/tests/ghci/scripts/ghci046.stdout2
-rw-r--r--testsuite/tests/indexed-types/should_fail/T7102.script5
-rw-r--r--testsuite/tests/indexed-types/should_fail/T7102.stdout0
-rw-r--r--testsuite/tests/indexed-types/should_fail/T7102A.hs3
-rw-r--r--testsuite/tests/indexed-types/should_fail/T7102B.hs6
-rw-r--r--testsuite/tests/indexed-types/should_fail/T7102C.hs6
-rw-r--r--testsuite/tests/indexed-types/should_fail/T7102a.script4
-rw-r--r--testsuite/tests/indexed-types/should_fail/T7102a.stderr5
-rw-r--r--testsuite/tests/indexed-types/should_fail/all.T2
11 files changed, 38 insertions, 1 deletions
diff --git a/testsuite/tests/ghci/scripts/ghci046.script b/testsuite/tests/ghci/scripts/ghci046.script
index 28c5cde050..eee3683c07 100644
--- a/testsuite/tests/ghci/scripts/ghci046.script
+++ b/testsuite/tests/ghci/scripts/ghci046.script
@@ -1,4 +1,5 @@
--Testing type families and their shadowing
+--(But type families no longer shadow, after #7102)
:set -XTypeFamilies
data HTrue
data HFalse
diff --git a/testsuite/tests/ghci/scripts/ghci046.stderr b/testsuite/tests/ghci/scripts/ghci046.stderr
new file mode 100644
index 0000000000..e6a2bd0bfd
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/ghci046.stderr
@@ -0,0 +1,5 @@
+
+<interactive>:7:15: error:
+ Conflicting family instance declarations:
+ AND HTrue HTrue = HTrue -- Defined at <interactive>:7:15
+ AND HTrue HTrue = HFalse -- Defined at <interactive>:20:15
diff --git a/testsuite/tests/ghci/scripts/ghci046.stdout b/testsuite/tests/ghci/scripts/ghci046.stdout
index c4e7cf3fc7..921e453808 100644
--- a/testsuite/tests/ghci/scripts/ghci046.stdout
+++ b/testsuite/tests/ghci/scripts/ghci046.stdout
@@ -3,4 +3,4 @@ AND HTrue HTrue :: *
AND (OR HFalse HTrue) (OR HTrue HFalse) :: *
= HTrue
t :: HTrue
-t :: HFalse
+t :: HTrue
diff --git a/testsuite/tests/indexed-types/should_fail/T7102.script b/testsuite/tests/indexed-types/should_fail/T7102.script
new file mode 100644
index 0000000000..6069cfd6c6
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/T7102.script
@@ -0,0 +1,5 @@
+:l T7102B T7102C
+:m +T7102C
+-- The empty T7102.stdout asserts that this :t fails
+-- (maybe because the earlier commands already did)
+:t to . from
diff --git a/testsuite/tests/indexed-types/should_fail/T7102.stdout b/testsuite/tests/indexed-types/should_fail/T7102.stdout
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/T7102.stdout
diff --git a/testsuite/tests/indexed-types/should_fail/T7102A.hs b/testsuite/tests/indexed-types/should_fail/T7102A.hs
new file mode 100644
index 0000000000..86630bbf23
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/T7102A.hs
@@ -0,0 +1,3 @@
+{-# LANGUAGE TypeFamilies #-}
+module T7102A where
+type family T a b
diff --git a/testsuite/tests/indexed-types/should_fail/T7102B.hs b/testsuite/tests/indexed-types/should_fail/T7102B.hs
new file mode 100644
index 0000000000..be2c17b962
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/T7102B.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE TypeFamilies #-}
+module T7102B where
+import T7102A
+type instance T a b = a
+from :: a -> T a b
+from = id
diff --git a/testsuite/tests/indexed-types/should_fail/T7102C.hs b/testsuite/tests/indexed-types/should_fail/T7102C.hs
new file mode 100644
index 0000000000..b2cbe5f1b9
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/T7102C.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE TypeFamilies #-}
+module T7102C where
+import T7102A
+type instance T a b = b
+to :: T a b -> b
+to = id
diff --git a/testsuite/tests/indexed-types/should_fail/T7102a.script b/testsuite/tests/indexed-types/should_fail/T7102a.script
new file mode 100644
index 0000000000..40e1bada01
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/T7102a.script
@@ -0,0 +1,4 @@
+:set -XTypeFamilies
+type family A a
+type instance A Int = ()
+type instance A Int = Bool
diff --git a/testsuite/tests/indexed-types/should_fail/T7102a.stderr b/testsuite/tests/indexed-types/should_fail/T7102a.stderr
new file mode 100644
index 0000000000..8dd542391b
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/T7102a.stderr
@@ -0,0 +1,5 @@
+
+<interactive>:3:15: error:
+ Conflicting family instance declarations:
+ A Int = () -- Defined at <interactive>:3:15
+ A Int = Bool -- Defined at <interactive>:4:15
diff --git a/testsuite/tests/indexed-types/should_fail/all.T b/testsuite/tests/indexed-types/should_fail/all.T
index 4e3927797c..7f23c34fc5 100644
--- a/testsuite/tests/indexed-types/should_fail/all.T
+++ b/testsuite/tests/indexed-types/should_fail/all.T
@@ -128,3 +128,5 @@ test('T11450', normal, compile_fail, [''])
test('T12041', normal, compile_fail, [''])
test('T12522a', normal, compile_fail, [''])
test('T12867', normal, compile_fail, [''])
+test('T7102', [ expect_broken(7102) ], ghci_script, ['T7102.script'])
+test('T7102a', normal, ghci_script, ['T7102a.script'])