diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2018-05-24 10:33:51 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2018-05-24 10:33:51 -0400 |
commit | 979f085c4f87a93f48d6b567076d3c556d490fa8 (patch) | |
tree | b1bc4eb705d16531780111bb5c828d370a5bcd65 /testsuite/tests/indexed-types | |
parent | 1879d9d2c95239f6705af0cbac5fed7d9b220f28 (diff) | |
download | haskell-979f085c4f87a93f48d6b567076d3c556d490fa8.tar.gz |
Clean up the conflicting data family instances error message
Summary:
The way we were pretty-printing conflicting data family
instances in an error message was far from ideal:
1. If a data type had no constructors, it would print an equals sign
with nothing to the right of it.
2. It would try to print GADTs using Haskell98 syntax.
3. It eta-reduced away some type variables from the LHS.
This patch addresses these three issues:
1. We no longer print constructors at all in this error message.
There's really no reason to do so in the first place, since
duplicate data family instances always conflict, regardless of
their constructors.
2. Since we no longer print constructors, we no longer have to
worry about whether we're using GADT or Haskell98 syntax.
3. I've put in a fix to ensure that type variables are no longer
eta-reduced away from the LHS.
Test Plan: make test TEST=T14179
Reviewers: goldfire, bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie, carter
GHC Trac Issues: #14179
Differential Revision: https://phabricator.haskell.org/D4711
Diffstat (limited to 'testsuite/tests/indexed-types')
13 files changed, 76 insertions, 42 deletions
diff --git a/testsuite/tests/indexed-types/should_fail/Over.stderr b/testsuite/tests/indexed-types/should_fail/Over.stderr index 63b8b304b2..3e0bc44b57 100644 --- a/testsuite/tests/indexed-types/should_fail/Over.stderr +++ b/testsuite/tests/indexed-types/should_fail/Over.stderr @@ -1,8 +1,8 @@ OverB.hs:7:15: error: Conflicting family instance declarations: - C [Int] [a] = CListList2 -- Defined at OverB.hs:7:15 - C [a] [Int] = C9ListList -- Defined at OverC.hs:7:15 + C [Int] [a] -- Defined at OverB.hs:7:15 + C [a] [Int] -- Defined at OverC.hs:7:15 OverB.hs:9:15: error: Conflicting family instance declarations: diff --git a/testsuite/tests/indexed-types/should_fail/OverDirectThisMod.stderr b/testsuite/tests/indexed-types/should_fail/OverDirectThisMod.stderr index 28c72df6e0..99a3377eb0 100644 --- a/testsuite/tests/indexed-types/should_fail/OverDirectThisMod.stderr +++ b/testsuite/tests/indexed-types/should_fail/OverDirectThisMod.stderr @@ -1,8 +1,8 @@ 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 + C [Int] [a] -- Defined at OverDirectThisModB.hs:7:15 + C [a] [Int] -- Defined at OverDirectThisModC.hs:10:15 OverDirectThisModB.hs:9:15: error: Conflicting family instance declarations: diff --git a/testsuite/tests/indexed-types/should_fail/OverIndirectThisMod.stderr b/testsuite/tests/indexed-types/should_fail/OverIndirectThisMod.stderr index 53c93e80ce..af136704db 100644 --- a/testsuite/tests/indexed-types/should_fail/OverIndirectThisMod.stderr +++ b/testsuite/tests/indexed-types/should_fail/OverIndirectThisMod.stderr @@ -1,10 +1,8 @@ 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 + C [Int] [a] -- Defined at OverIndirectThisModB.hs:7:15 + C [a] [Int] -- Defined at OverIndirectThisModD.hs:11:15 OverIndirectThisModB.hs:9:15: error: Conflicting family instance declarations: diff --git a/testsuite/tests/indexed-types/should_fail/SimpleFail11a.stderr b/testsuite/tests/indexed-types/should_fail/SimpleFail11a.stderr index d467019760..41ed865dfb 100644 --- a/testsuite/tests/indexed-types/should_fail/SimpleFail11a.stderr +++ b/testsuite/tests/indexed-types/should_fail/SimpleFail11a.stderr @@ -1,10 +1,10 @@ -SimpleFail11a.hs:6:15: +SimpleFail11a.hs:6:15: error: Conflicting family instance declarations: - C9 Int Int = C9IntInt -- Defined at SimpleFail11a.hs:6:15 - C9 Int Int = C9IntInt2 -- Defined at SimpleFail11a.hs:8:15 + C9 Int Int -- Defined at SimpleFail11a.hs:6:15 + C9 Int Int -- Defined at SimpleFail11a.hs:8:15 -SimpleFail11a.hs:11:15: +SimpleFail11a.hs:11:15: error: Conflicting family instance declarations: D9 Int Int = Char -- Defined at SimpleFail11a.hs:11:15 D9 Int Int = Int -- Defined at SimpleFail11a.hs:13:15 diff --git a/testsuite/tests/indexed-types/should_fail/SimpleFail11b.stderr b/testsuite/tests/indexed-types/should_fail/SimpleFail11b.stderr index e40a3a6b4e..bd05039dc8 100644 --- a/testsuite/tests/indexed-types/should_fail/SimpleFail11b.stderr +++ b/testsuite/tests/indexed-types/should_fail/SimpleFail11b.stderr @@ -1,10 +1,10 @@ -SimpleFail11b.hs:7:15: +SimpleFail11b.hs:7:15: error: Conflicting family instance declarations: - C9 [a] Int = C9ListInt -- Defined at SimpleFail11b.hs:7:15 - C9 [a] Int = C9ListInt2 -- Defined at SimpleFail11b.hs:9:15 + C9 [a] Int -- Defined at SimpleFail11b.hs:7:15 + C9 [a] Int -- Defined at SimpleFail11b.hs:9:15 -SimpleFail11b.hs:13:15: +SimpleFail11b.hs:13:15: error: Conflicting family instance declarations: D9 [a] Int = [a] -- Defined at SimpleFail11b.hs:13:15 D9 [a] Int = Maybe a -- Defined at SimpleFail11b.hs:15:15 diff --git a/testsuite/tests/indexed-types/should_fail/SimpleFail11c.stderr b/testsuite/tests/indexed-types/should_fail/SimpleFail11c.stderr index d4a1bb4f30..cbb457933b 100644 --- a/testsuite/tests/indexed-types/should_fail/SimpleFail11c.stderr +++ b/testsuite/tests/indexed-types/should_fail/SimpleFail11c.stderr @@ -1,10 +1,10 @@ -SimpleFail11c.hs:7:15: +SimpleFail11c.hs:7:15: error: Conflicting family instance declarations: - C9 [a] Int = C9ListInt -- Defined at SimpleFail11c.hs:7:15 - C9 [Int] Int = C9ListInt2 -- Defined at SimpleFail11c.hs:9:15 + C9 [a] Int -- Defined at SimpleFail11c.hs:7:15 + C9 [Int] Int -- Defined at SimpleFail11c.hs:9:15 -SimpleFail11c.hs:13:15: +SimpleFail11c.hs:13:15: error: Conflicting family instance declarations: D9 [a] Int = [a] -- Defined at SimpleFail11c.hs:13:15 D9 [Int] Int = [Bool] -- Defined at SimpleFail11c.hs:15:15 diff --git a/testsuite/tests/indexed-types/should_fail/SimpleFail11d.stderr b/testsuite/tests/indexed-types/should_fail/SimpleFail11d.stderr index cdd8afda96..48d3c33fef 100644 --- a/testsuite/tests/indexed-types/should_fail/SimpleFail11d.stderr +++ b/testsuite/tests/indexed-types/should_fail/SimpleFail11d.stderr @@ -1,5 +1,5 @@ -SimpleFail11d.hs:8:15: +SimpleFail11d.hs:8:15: error: Conflicting family instance declarations: - C9 [Int] [a] = C9ListList2 -- Defined at SimpleFail11d.hs:8:15 - C9 [a] [Int] = C9ListList -- Defined at SimpleFail11d.hs:10:15 + C9 [Int] [a] -- Defined at SimpleFail11d.hs:8:15 + C9 [a] [Int] -- Defined at SimpleFail11d.hs:10:15 diff --git a/testsuite/tests/indexed-types/should_fail/SimpleFail2b.stderr b/testsuite/tests/indexed-types/should_fail/SimpleFail2b.stderr index bb0aaca16c..88fdfe127c 100644 --- a/testsuite/tests/indexed-types/should_fail/SimpleFail2b.stderr +++ b/testsuite/tests/indexed-types/should_fail/SimpleFail2b.stderr @@ -1,5 +1,5 @@ -SimpleFail2b.hs:9:11: +SimpleFail2b.hs:9:11: error: Conflicting family instance declarations: - Sd Int = SdC1 Char -- Defined at SimpleFail2b.hs:9:11 - Sd Int = SdC2 Char -- Defined at SimpleFail2b.hs:10:11 + Sd Int -- Defined at SimpleFail2b.hs:9:11 + Sd Int -- Defined at SimpleFail2b.hs:10:11 diff --git a/testsuite/tests/indexed-types/should_fail/T14179.hs b/testsuite/tests/indexed-types/should_fail/T14179.hs new file mode 100644 index 0000000000..60c8a94c39 --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T14179.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE GADTs #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE TypeFamilies #-} +module T14179 where + +data family Foo1 a +data instance Foo1 a +data instance Foo1 a + +data family Foo2 :: k -> * +data instance Foo2 :: * -> * +data instance Foo2 :: * -> * + +data family Foo3 a +data instance Foo3 [a] where + Foo3a :: Foo3 [Int] + Foo3b :: Foo3 [Bool] +data instance Foo3 [a] where + Foo3c :: Foo3 [a] + Foo3d :: Foo3 [Char] diff --git a/testsuite/tests/indexed-types/should_fail/T14179.stderr b/testsuite/tests/indexed-types/should_fail/T14179.stderr new file mode 100644 index 0000000000..38d77f1cca --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T14179.stderr @@ -0,0 +1,15 @@ + +T14179.hs:7:15: error: + Conflicting family instance declarations: + Foo1 a -- Defined at T14179.hs:7:15 + Foo1 a -- Defined at T14179.hs:8:15 + +T14179.hs:11:15: error: + Conflicting family instance declarations: + Foo2 a -- Defined at T14179.hs:11:15 + Foo2 a -- Defined at T14179.hs:12:15 + +T14179.hs:15:15: error: + Conflicting family instance declarations: + Foo3 [a] -- Defined at T14179.hs:15:15 + Foo3 [a] -- Defined at T14179.hs:18:15 diff --git a/testsuite/tests/indexed-types/should_fail/T2334A.stderr b/testsuite/tests/indexed-types/should_fail/T2334A.stderr index 7b7d265d61..a5bc0a0e78 100644 --- a/testsuite/tests/indexed-types/should_fail/T2334A.stderr +++ b/testsuite/tests/indexed-types/should_fail/T2334A.stderr @@ -1,17 +1,17 @@ -T2334A.hs:9:26: - The constructor of a newtype must have exactly one field - but ‘F’ has two - In the definition of data constructor ‘F’ - In the newtype instance declaration for ‘F’ +T2334A.hs:9:26: error: + • The constructor of a newtype must have exactly one field + but ‘F’ has two + • In the definition of data constructor ‘F’ + In the newtype instance declaration for ‘F’ -T2334A.hs:10:27: - The constructor of a newtype must have exactly one field - but ‘H’ has none - In the definition of data constructor ‘H’ - In the newtype instance declaration for ‘F’ +T2334A.hs:10:27: error: + • The constructor of a newtype must have exactly one field + but ‘H’ has none + • In the definition of data constructor ‘H’ + In the newtype instance declaration for ‘F’ -T2334A.hs:12:15: +T2334A.hs:12:15: error: Conflicting family instance declarations: - F Bool = K1 -- Defined at T2334A.hs:12:15 - F Bool = K2 -- Defined at T2334A.hs:13:15 + F Bool -- Defined at T2334A.hs:12:15 + F Bool -- Defined at T2334A.hs:13:15 diff --git a/testsuite/tests/indexed-types/should_fail/T9371.stderr b/testsuite/tests/indexed-types/should_fail/T9371.stderr index 729ee3a8c0..9207ac5ae2 100644 --- a/testsuite/tests/indexed-types/should_fail/T9371.stderr +++ b/testsuite/tests/indexed-types/should_fail/T9371.stderr @@ -1,5 +1,5 @@ -T9371.hs:14:10: +T9371.hs:14:10: error: Conflicting family instance declarations: - D = D1 (Either x ()) -- Defined at T9371.hs:14:10 - D (x, y) = D2 (x, y) -- Defined at T9371.hs:18:10 + D x -- Defined at T9371.hs:14:10 + D (x, y) -- Defined at T9371.hs:18:10 diff --git a/testsuite/tests/indexed-types/should_fail/all.T b/testsuite/tests/indexed-types/should_fail/all.T index 61025d6c92..80ea5dafa9 100644 --- a/testsuite/tests/indexed-types/should_fail/all.T +++ b/testsuite/tests/indexed-types/should_fail/all.T @@ -140,5 +140,6 @@ test('T13972', normal, compile_fail, ['']) test('T14033', normal, compile_fail, ['']) test('T14045a', normal, compile_fail, ['']) test('T14175', normal, compile_fail, ['']) +test('T14179', normal, compile_fail, ['']) test('T14369', normal, compile_fail, ['']) test('T15172', normal, compile_fail, ['']) |