diff options
author | Bartosz Nitka <niteria@gmail.com> | 2017-05-22 12:01:05 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-05-22 12:41:20 -0400 |
commit | 2bc3a0570dac333cc7fb6f8038e08f36d62e4d13 (patch) | |
tree | 20fd2ae60406eac0d24b214fd4d3fd3e54cca17d | |
parent | 17fef390c575c153c7e70438783e7f8fee62e451 (diff) | |
download | haskell-2bc3a0570dac333cc7fb6f8038e08f36d62e4d13.tar.gz |
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
11 files changed, 87 insertions, 0 deletions
diff --git a/testsuite/tests/indexed-types/should_fail/OverD.hs b/testsuite/tests/indexed-types/should_fail/OverD.hs index 3bce8de55e..ec57974070 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 0000000000..28c72df6e0 --- /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/OverDirectThisModA.hs b/testsuite/tests/indexed-types/should_fail/OverDirectThisModA.hs new file mode 100644 index 0000000000..d2655b6937 --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/OverDirectThisModA.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE TypeFamilies #-} + +module OverDirectThisModA (C, D) +where + +data family C a b :: * + +type family D 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 0000000000..4215edfda4 --- /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 0000000000..aa0f88823e --- /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 0000000000..53c93e80ce --- /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/OverIndirectThisModA.hs b/testsuite/tests/indexed-types/should_fail/OverIndirectThisModA.hs new file mode 100644 index 0000000000..f316ac159c --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/OverIndirectThisModA.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE TypeFamilies #-} + +module OverIndirectThisModA (C, D) +where + +data family C a b :: * + +type family D 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 0000000000..ed152d557f --- /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 0000000000..e39a27dff0 --- /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 0000000000..a75007b451 --- /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 cca1e8dcad..9cad8e1734 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, ['']) |