summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorHE, Tao <sighingnow@gmail.com>2018-02-12 19:55:41 -0500
committerBen Gamari <ben@smart-cactus.org>2018-02-13 17:49:43 -0500
commit8936ab69d18669bab3ca4edf40458f88ae5903f0 (patch)
treef793c1a8f115a0956386a78f355d30836805272e /testsuite
parent0c9777b787d072f9f57e0cdfe44e2e2d48217077 (diff)
downloadhaskell-8936ab69d18669bab3ca4edf40458f88ae5903f0.tar.gz
Raise parse error for `data T where`.
Empty GADTs data declarations can't be identified in type checker. This patch adds additional checks in parser and raise a parse error when encounter empty GADTs declarations but extension `GADTs` is not enabled. Only empty declarations are checked in parser to avoid affecting existing error messages related to missing GADTs extension. This patch should fix issue 8258. Signed-off-by: HE, Tao <sighingnow@gmail.com> Test Plan: make test TEST="T8258 T8258NoGADTs" Reviewers: bgamari, mpickering, alanz, RyanGlScott Reviewed By: bgamari, RyanGlScott Subscribers: adamse, RyanGlScott, rwbarton, thomie, mpickering, carter GHC Trac Issues: #8258 Differential Revision: https://phabricator.haskell.org/D4350
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/parser/should_compile/T8258.hs5
-rw-r--r--testsuite/tests/parser/should_compile/all.T1
-rw-r--r--testsuite/tests/parser/should_fail/T8258NoGADTs.hs3
-rw-r--r--testsuite/tests/parser/should_fail/T8258NoGADTs.stderr5
-rw-r--r--testsuite/tests/parser/should_fail/all.T1
-rw-r--r--testsuite/tests/polykinds/T11640.hs2
-rw-r--r--testsuite/tests/typecheck/should_compile/tc247.hs2
7 files changed, 17 insertions, 2 deletions
diff --git a/testsuite/tests/parser/should_compile/T8258.hs b/testsuite/tests/parser/should_compile/T8258.hs
new file mode 100644
index 0000000000..18d6483973
--- /dev/null
+++ b/testsuite/tests/parser/should_compile/T8258.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE GADTs #-}
+
+module T8258 where
+
+data T where
diff --git a/testsuite/tests/parser/should_compile/all.T b/testsuite/tests/parser/should_compile/all.T
index cc9771087f..1ca6d7ebad 100644
--- a/testsuite/tests/parser/should_compile/all.T
+++ b/testsuite/tests/parser/should_compile/all.T
@@ -100,6 +100,7 @@ test('T7118', normal, compile, [''])
test('T7776', normal, compile, [''])
test('RdrNoStaticPointers01', [], compile, [''])
test('T5682', normal, compile, [''])
+test('T8258', normal, compile, [''])
test('T9723a', normal, compile, [''])
test('T9723b', normal, compile, [''])
test('T10188', normal, compile, [''])
diff --git a/testsuite/tests/parser/should_fail/T8258NoGADTs.hs b/testsuite/tests/parser/should_fail/T8258NoGADTs.hs
new file mode 100644
index 0000000000..1080233bcd
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T8258NoGADTs.hs
@@ -0,0 +1,3 @@
+module T8258NoGADTs where
+
+data T where
diff --git a/testsuite/tests/parser/should_fail/T8258NoGADTs.stderr b/testsuite/tests/parser/should_fail/T8258NoGADTs.stderr
new file mode 100644
index 0000000000..35f5306274
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T8258NoGADTs.stderr
@@ -0,0 +1,5 @@
+
+T8258NoGADTs.hs:3:8: error:
+ Illegal keyword 'where' in data declaration
+ Perhaps you intended to use GADTs or a similar language
+ extension to enable syntax: data T where
diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T
index ef47ed3394..2cb9c49de2 100644
--- a/testsuite/tests/parser/should_fail/all.T
+++ b/testsuite/tests/parser/should_fail/all.T
@@ -87,6 +87,7 @@ test('T5425', normal, compile_fail, [''])
test('T984', normal, compile_fail, [''])
test('T7848', normal, compile_fail, ['-dppr-user-length=100'])
test('ExportCommaComma', normal, compile_fail, [''])
+test('T8258NoGADTs', normal, compile_fail, [''])
test('T8430', literate, compile_fail, [''])
test('T8431', compile_timeout_multiplier(0.05),
compile_fail, ['-XAlternativeLayoutRule'])
diff --git a/testsuite/tests/polykinds/T11640.hs b/testsuite/tests/polykinds/T11640.hs
index 16d9f7ccff..bbb4a53bfc 100644
--- a/testsuite/tests/polykinds/T11640.hs
+++ b/testsuite/tests/polykinds/T11640.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE RankNTypes, TypeInType #-}
+{-# LANGUAGE GADTs, RankNTypes, TypeInType #-}
module T11640 where
diff --git a/testsuite/tests/typecheck/should_compile/tc247.hs b/testsuite/tests/typecheck/should_compile/tc247.hs
index 0f017a02db..abfc9ac9a4 100644
--- a/testsuite/tests/typecheck/should_compile/tc247.hs
+++ b/testsuite/tests/typecheck/should_compile/tc247.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE EmptyDataDecls, KindSignatures #-}
+{-# LANGUAGE GADTs, EmptyDataDecls, KindSignatures #-}
module ShouldCompile where