[commit: ghc] master: Testcase for type family consistency checks (2bc3a05)
git at git.haskell.org
git at git.haskell.org
Mon May 22 16:41:46 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/2bc3a0570dac333cc7fb6f8038e08f36d62e4d13/ghc
>---------------------------------------------------------------
commit 2bc3a0570dac333cc7fb6f8038e08f36d62e4d13
Author: Bartosz Nitka <niteria at gmail.com>
Date: Mon May 22 12:01:05 2017 -0400
Testcase for type family consistency checks
Based on my quick search, we don't have a test
that verifies that we check the type family instances of
currently compiled module against direct or indirect
dependencies.
This adds two tests: for a direct dependency and
for an indirect dependency.
I also added a comment to make it clear what the 'Over'
test tests.
Other than completeness, it makes sense to have these
tests because if you look at
Note [The type family instance consistency story] in FamInsts
these cases are checked through different mechanisms.
Test Plan: new tests
Reviewers: simonmar, rwbarton, simonpj, austin, bgamari
Reviewed By: simonpj, bgamari
Subscribers: thomie
GHC Trac Issues: #13719
Differential Revision: https://phabricator.haskell.org/D3602
>---------------------------------------------------------------
2bc3a0570dac333cc7fb6f8038e08f36d62e4d13
testsuite/tests/indexed-types/should_fail/OverD.hs | 2 ++
.../indexed-types/should_fail/OverDirectThisMod.stderr | 10 ++++++++++
.../should_fail/{OverA.hs => OverDirectThisModA.hs} | 2 +-
.../tests/indexed-types/should_fail/OverDirectThisModB.hs | 9 +++++++++
.../tests/indexed-types/should_fail/OverDirectThisModC.hs | 12 ++++++++++++
.../indexed-types/should_fail/OverIndirectThisMod.stderr | 12 ++++++++++++
.../should_fail/{OverA.hs => OverIndirectThisModA.hs} | 2 +-
.../tests/indexed-types/should_fail/OverIndirectThisModB.hs | 9 +++++++++
.../tests/indexed-types/should_fail/OverIndirectThisModC.hs | 2 ++
.../tests/indexed-types/should_fail/OverIndirectThisModD.hs | 13 +++++++++++++
testsuite/tests/indexed-types/should_fail/all.T | 2 ++
11 files changed, 73 insertions(+), 2 deletions(-)
diff --git a/testsuite/tests/indexed-types/should_fail/OverD.hs b/testsuite/tests/indexed-types/should_fail/OverD.hs
index 3bce8de..ec57974 100644
--- a/testsuite/tests/indexed-types/should_fail/OverD.hs
+++ b/testsuite/tests/indexed-types/should_fail/OverD.hs
@@ -1,3 +1,5 @@
module OverD where
+-- Tests that we verify consistency of type families between
+-- transitive imports.
import OverB
import OverC
diff --git a/testsuite/tests/indexed-types/should_fail/OverDirectThisMod.stderr b/testsuite/tests/indexed-types/should_fail/OverDirectThisMod.stderr
new file mode 100644
index 0000000..28c72df
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/OverDirectThisMod.stderr
@@ -0,0 +1,10 @@
+
+OverDirectThisModB.hs:7:15: error:
+ Conflicting family instance declarations:
+ C [Int] [a] = CListList2 -- Defined at OverDirectThisModB.hs:7:15
+ C [a] [Int] = C9ListList -- Defined at OverDirectThisModC.hs:10:15
+
+OverDirectThisModB.hs:9:15: error:
+ Conflicting family instance declarations:
+ D [Int] [a] = Int -- Defined at OverDirectThisModB.hs:9:15
+ D [a] [Int] = Char -- Defined at OverDirectThisModC.hs:12:15
diff --git a/testsuite/tests/indexed-types/should_fail/OverA.hs b/testsuite/tests/indexed-types/should_fail/OverDirectThisModA.hs
similarity index 52%
copy from testsuite/tests/indexed-types/should_fail/OverA.hs
copy to testsuite/tests/indexed-types/should_fail/OverDirectThisModA.hs
index 0f05737..d2655b6 100644
--- a/testsuite/tests/indexed-types/should_fail/OverA.hs
+++ b/testsuite/tests/indexed-types/should_fail/OverDirectThisModA.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE TypeFamilies #-}
-module OverA (C, D)
+module OverDirectThisModA (C, D)
where
data family C a b :: *
diff --git a/testsuite/tests/indexed-types/should_fail/OverDirectThisModB.hs b/testsuite/tests/indexed-types/should_fail/OverDirectThisModB.hs
new file mode 100644
index 0000000..4215edf
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/OverDirectThisModB.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE TypeFamilies #-}
+
+module OverDirectThisModB
+where
+import OverDirectThisModA (C, D)
+
+data instance C [Int] [a] = CListList2
+
+type instance D [Int] [a] = Int
diff --git a/testsuite/tests/indexed-types/should_fail/OverDirectThisModC.hs b/testsuite/tests/indexed-types/should_fail/OverDirectThisModC.hs
new file mode 100644
index 0000000..aa0f888
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/OverDirectThisModC.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE TypeFamilies #-}
+-- Tests that we check family instance consistency between
+-- type family instances defined in the currently compiled module
+-- and the direct imports.
+module OverDirectThisModC
+where
+import OverDirectThisModB
+import OverDirectThisModA (C, D)
+
+data instance C [a] [Int] = C9ListList
+
+type instance D [a] [Int] = Char
diff --git a/testsuite/tests/indexed-types/should_fail/OverIndirectThisMod.stderr b/testsuite/tests/indexed-types/should_fail/OverIndirectThisMod.stderr
new file mode 100644
index 0000000..53c93e8
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/OverIndirectThisMod.stderr
@@ -0,0 +1,12 @@
+
+OverIndirectThisModB.hs:7:15: error:
+ Conflicting family instance declarations:
+ C [Int] [a] = OverIndirectThisModB.CListList2
+ -- Defined at OverIndirectThisModB.hs:7:15
+ C [a] [Int] = C9ListList
+ -- Defined at OverIndirectThisModD.hs:11:15
+
+OverIndirectThisModB.hs:9:15: error:
+ Conflicting family instance declarations:
+ D [Int] [a] = Int -- Defined at OverIndirectThisModB.hs:9:15
+ D [a] [Int] = Char -- Defined at OverIndirectThisModD.hs:13:15
diff --git a/testsuite/tests/indexed-types/should_fail/OverA.hs b/testsuite/tests/indexed-types/should_fail/OverIndirectThisModA.hs
similarity index 51%
copy from testsuite/tests/indexed-types/should_fail/OverA.hs
copy to testsuite/tests/indexed-types/should_fail/OverIndirectThisModA.hs
index 0f05737..f316ac1 100644
--- a/testsuite/tests/indexed-types/should_fail/OverA.hs
+++ b/testsuite/tests/indexed-types/should_fail/OverIndirectThisModA.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE TypeFamilies #-}
-module OverA (C, D)
+module OverIndirectThisModA (C, D)
where
data family C a b :: *
diff --git a/testsuite/tests/indexed-types/should_fail/OverIndirectThisModB.hs b/testsuite/tests/indexed-types/should_fail/OverIndirectThisModB.hs
new file mode 100644
index 0000000..ed152d5
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/OverIndirectThisModB.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE TypeFamilies #-}
+
+module OverIndirectThisModB
+where
+import OverIndirectThisModA (C, D)
+
+data instance C [Int] [a] = CListList2
+
+type instance D [Int] [a] = Int
diff --git a/testsuite/tests/indexed-types/should_fail/OverIndirectThisModC.hs b/testsuite/tests/indexed-types/should_fail/OverIndirectThisModC.hs
new file mode 100644
index 0000000..e39a27d
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/OverIndirectThisModC.hs
@@ -0,0 +1,2 @@
+module OverIndirectThisModC where
+import OverIndirectThisModB
diff --git a/testsuite/tests/indexed-types/should_fail/OverIndirectThisModD.hs b/testsuite/tests/indexed-types/should_fail/OverIndirectThisModD.hs
new file mode 100644
index 0000000..a75007b
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/OverIndirectThisModD.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE TypeFamilies #-}
+-- Tests that we check family instance consistency between
+-- type family instances defined in the currently compiled module
+-- and the transitive imports.
+module OverIndirectThisModD
+where
+import OverIndirectThisModC
+ -- imports OverIndirectThisModB with conflicting instances
+import OverIndirectThisModA (C, D)
+
+data instance C [a] [Int] = C9ListList
+
+type instance D [a] [Int] = Char
diff --git a/testsuite/tests/indexed-types/should_fail/all.T b/testsuite/tests/indexed-types/should_fail/all.T
index cca1e8d..9cad8e1 100644
--- a/testsuite/tests/indexed-types/should_fail/all.T
+++ b/testsuite/tests/indexed-types/should_fail/all.T
@@ -30,6 +30,8 @@ test('NonLinearSigErr', normal, compile, [''])
test('GADTwrong1', normal, compile_fail, [''])
test('Over', [], multimod_compile_fail, ['OverD', '-no-hs-main -c -v0'])
+test('OverDirectThisMod', [], multimod_compile_fail, ['OverDirectThisModC', '-no-hs-main -c -v0'])
+test('OverIndirectThisMod', [], multimod_compile_fail, ['OverIndirectThisModD', '-no-hs-main -c -v0'])
test('SkolemOccursLoop', expect_fail, compile_fail, [''])
More information about the ghc-commits
mailing list