Add a failing test for #13102
authorReid Barton <rwbarton@gmail.com>
Tue, 24 Jan 2017 02:59:39 +0000 (21:59 -0500)
committerBen Gamari <ben@smart-cactus.org>
Tue, 24 Jan 2017 03:05:53 +0000 (22:05 -0500)
Test Plan: harbormaster

Reviewers: austin, ezyang, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D3005

GHC Trac Issues: #13102

testsuite/tests/indexed-types/should_fail/T13102/A.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13102/B.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13102/Makefile [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13102/T13102.stderr [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13102/all.T [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13102/orphan/F.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13102/orphan/O.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13102/orphan/Setup.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13102/orphan/orphan.cabal [new file with mode: 0644]

diff --git a/testsuite/tests/indexed-types/should_fail/T13102/A.hs b/testsuite/tests/indexed-types/should_fail/T13102/A.hs
new file mode 100644 (file)
index 0000000..7dd4348
--- /dev/null
@@ -0,0 +1,6 @@
+module A where
+
+import O
+
+x _ = 1 -- Generate a silly warning, so we know A was really compiled
+x _ = 2 -- (and thus the reason B fails is that the bug is fixed)
diff --git a/testsuite/tests/indexed-types/should_fail/T13102/B.hs b/testsuite/tests/indexed-types/should_fail/T13102/B.hs
new file mode 100644 (file)
index 0000000..ab8832b
--- /dev/null
@@ -0,0 +1,6 @@
+module B where
+
+import F
+
+f :: F Int -> Bool
+f = id
diff --git a/testsuite/tests/indexed-types/should_fail/T13102/Makefile b/testsuite/tests/indexed-types/should_fail/T13102/Makefile
new file mode 100644 (file)
index 0000000..b4cbff9
--- /dev/null
@@ -0,0 +1,13 @@
+TOP=../../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+LOCAL_PKGCONF=local.package.conf
+
+T13102:
+       "$(GHC_PKG)" init $(LOCAL_PKGCONF)
+       cd orphan && "$(TEST_HC)" -v0 --make Setup.hs
+       cd orphan && ./Setup configure -v0 --with-compiler="$(TEST_HC)" --with-hc-pkg="$(GHC_PKG)" --package-db=../$(LOCAL_PKGCONF)
+       cd orphan && ./Setup build -v0
+       cd orphan && ./Setup register -v0 --inplace
+       ! "$(TEST_HC)" $(TEST_HC_OPTS) -c A.hs B.hs -package-db $(LOCAL_PKGCONF)
diff --git a/testsuite/tests/indexed-types/should_fail/T13102/T13102.stderr b/testsuite/tests/indexed-types/should_fail/T13102/T13102.stderr
new file mode 100644 (file)
index 0000000..e884cba
--- /dev/null
@@ -0,0 +1,11 @@
+
+A.hs:6:1: warning: [-Woverlapping-patterns (in -Wdefault)]
+    Pattern match is redundant
+    In an equation for ‘x’: x _ = ...
+
+B.hs:6:5: error:
+    • Couldn't match type ‘F Int’ with ‘Bool’
+      Expected type: F Int -> Bool
+        Actual type: Bool -> Bool
+    • In the expression: id
+      In an equation for ‘f’: f = id
diff --git a/testsuite/tests/indexed-types/should_fail/T13102/all.T b/testsuite/tests/indexed-types/should_fail/T13102/all.T
new file mode 100644 (file)
index 0000000..bdde354
--- /dev/null
@@ -0,0 +1,5 @@
+# Test that we don't use a family instance that we didn't import
+
+test('T13102', [expect_broken(13102),
+     extra_files(['A.hs', 'B.hs', 'orphan'])],
+     run_command, ['$MAKE -s --no-print-directory T13102'])
diff --git a/testsuite/tests/indexed-types/should_fail/T13102/orphan/F.hs b/testsuite/tests/indexed-types/should_fail/T13102/orphan/F.hs
new file mode 100644 (file)
index 0000000..7e1ecf4
--- /dev/null
@@ -0,0 +1,5 @@
+{-# LANGUAGE TypeFamilies #-}
+
+module F where
+
+type family F a :: *
diff --git a/testsuite/tests/indexed-types/should_fail/T13102/orphan/O.hs b/testsuite/tests/indexed-types/should_fail/T13102/orphan/O.hs
new file mode 100644 (file)
index 0000000..b8608ec
--- /dev/null
@@ -0,0 +1,7 @@
+{-# LANGUAGE TypeFamilies #-}
+
+module O where
+
+import F
+
+type instance F Int = Bool
diff --git a/testsuite/tests/indexed-types/should_fail/T13102/orphan/Setup.hs b/testsuite/tests/indexed-types/should_fail/T13102/orphan/Setup.hs
new file mode 100644 (file)
index 0000000..9a994af
--- /dev/null
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/testsuite/tests/indexed-types/should_fail/T13102/orphan/orphan.cabal b/testsuite/tests/indexed-types/should_fail/T13102/orphan/orphan.cabal
new file mode 100644 (file)
index 0000000..c6a6ea0
--- /dev/null
@@ -0,0 +1,5 @@
+name: orphan
+version: 1.0
+exposed-modules: F, O
+build-depends: base
+build-type: Simple