diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-08-17 10:07:03 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-08-17 10:07:03 -0400 |
commit | 039fa1b994a8b0d6be25eb1bc711904db9661db2 (patch) | |
tree | 1ed9bec64b6aab32dbdcb4d13975424a86951ec9 /testsuite/tests/gadt | |
parent | 38260a9e9f8c38edd25f4b4c06e0ea5d88fc6bf2 (diff) | |
download | haskell-039fa1b994a8b0d6be25eb1bc711904db9661db2.tar.gz |
Suggest how to fix illegally nested foralls in GADT constructor type signatures
Summary:
Although the code from #12087 isn't accepted by GHC, we can at least
do a better job of letting users know what the problem is, and how to fix it.
Test Plan: make test TEST=T12087
Reviewers: goldfire, austin, bgamari
Reviewed By: goldfire
Subscribers: rwbarton, thomie
GHC Trac Issues: #12087
Differential Revision: https://phabricator.haskell.org/D3851
Diffstat (limited to 'testsuite/tests/gadt')
-rw-r--r-- | testsuite/tests/gadt/T12087.hs | 18 | ||||
-rw-r--r-- | testsuite/tests/gadt/T12087.stderr | 35 | ||||
-rw-r--r-- | testsuite/tests/gadt/all.T | 3 |
3 files changed, 55 insertions, 1 deletions
diff --git a/testsuite/tests/gadt/T12087.hs b/testsuite/tests/gadt/T12087.hs new file mode 100644 index 0000000000..e56240c2a4 --- /dev/null +++ b/testsuite/tests/gadt/T12087.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE GADTs #-} +{-# LANGUAGE RankNTypes #-} +module T12087 where + +data F1 a where + MkF1 :: Ord a => Eq a => a -> F1 a + +data F2 a where + MkF2 :: Ord a => a -> Eq a => F2 a + +data F3 a where + MkF3 :: forall a. Eq a => a -> forall b. Eq b => b -> F3 a + +data F4 a where + MkF4 :: forall a b. Eq a => a -> Eq b => b -> F4 a + +data F5 a where + MkF5 :: Int -> Int -> forall a. a -> Int -> Int -> forall b. b -> F5 a diff --git a/testsuite/tests/gadt/T12087.stderr b/testsuite/tests/gadt/T12087.stderr new file mode 100644 index 0000000000..03f2465c7a --- /dev/null +++ b/testsuite/tests/gadt/T12087.stderr @@ -0,0 +1,35 @@ + +T12087.hs:6:3: error: + • GADT constructor type signature cannot contain nested ‘forall’s or contexts + Suggestion: instead use this type signature: + MkF1 :: forall a. (Ord a, Eq a) => a -> F1 a + • In the definition of data constructor ‘MkF1’ + In the data type declaration for ‘F1’ + +T12087.hs:9:3: error: + • GADT constructor type signature cannot contain nested ‘forall’s or contexts + Suggestion: instead use this type signature: + MkF2 :: forall a. (Ord a, Eq a) => F2 a + • In the definition of data constructor ‘MkF2’ + In the data type declaration for ‘F2’ + +T12087.hs:12:3: error: + • GADT constructor type signature cannot contain nested ‘forall’s or contexts + Suggestion: instead use this type signature: + MkF3 :: forall a b. (Eq a, Eq b) => b -> F3 a + • In the definition of data constructor ‘MkF3’ + In the data type declaration for ‘F3’ + +T12087.hs:15:3: error: + • GADT constructor type signature cannot contain nested ‘forall’s or contexts + Suggestion: instead use this type signature: + MkF4 :: forall a b. (Eq a, Eq b) => b -> F4 a + • In the definition of data constructor ‘MkF4’ + In the data type declaration for ‘F4’ + +T12087.hs:18:3: error: + • GADT constructor type signature cannot contain nested ‘forall’s or contexts + Suggestion: instead use this type signature: + MkF5 :: forall a b. a -> Int -> Int -> b -> F5 a + • In the definition of data constructor ‘MkF5’ + In the data type declaration for ‘F5’ diff --git a/testsuite/tests/gadt/all.T b/testsuite/tests/gadt/all.T index 877943b0c5..3c825f0848 100644 --- a/testsuite/tests/gadt/all.T +++ b/testsuite/tests/gadt/all.T @@ -56,7 +56,7 @@ test('records-fail1', normal, compile_fail, ['']) test('doaitse', normal, compile, ['']) test('josef', normal, compile, ['']) -# Interaction of fundeps with GADTs doesn't work well +# Interaction of fundeps with GADTs doesn't work well test('gadt-fd', expect_broken(345), compile, ['']) test('karl1', normal, compile, ['']) @@ -112,4 +112,5 @@ test('T7974', normal, compile, ['']) test('T7558', normal, compile_fail, ['']) test('T9096', normal, compile, ['']) test('T9380', normal, compile_and_run, ['']) +test('T12087', normal, compile_fail, ['']) test('T12468', normal, compile_fail, ['']) |