summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2018-10-04 09:17:55 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2018-10-04 09:17:55 -0400
commitbd7898537768f936d05c0c83eef1cd9b00933347 (patch)
treedb16292d6c32f6ef04ff829178cacc6709d00a6d /testsuite
parentfc2ff6dd7496a33bf68165b28f37f40b7d647418 (diff)
downloadhaskell-bd7898537768f936d05c0c83eef1cd9b00933347.tar.gz
Parse the (!) type operator and allow type operators in existential context
Summary: Improve the way `(!)`, `(~)`, and other type operators are handled in the parser, fixing two issues at once: 1. `(!)` can now be used as a type operator that respects fixity and precedence (#15457) 2. Existential context of a data constructor no longer needs parentheses (#15675) In addition to that, with this patch it is now trivial to adjust precedence of the `{-# UNPACK #-}` pragma, as suggested in https://ghc.haskell.org/trac/ghc/ticket/14761#comment:7 There was a small change to API Annotations. Before this patch, `(~)` was a strange special case that produced an annotation unlike any other type operator. After this patch, when `(~)` or `(!)` are used to specify strictness they produce AnnTilde and AnnBang annotations respectively, and when they are used as type operators, they produce no annotations. Test Plan: Validate Reviewers: simonpj, bgamari, alanz, RyanGlScott Reviewed By: RyanGlScott Subscribers: RyanGlScott, rwbarton, mpickering, carter GHC Trac Issues: #15457, #15675 Differential Revision: https://phabricator.haskell.org/D5180
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/ghc-api/annotations/T11321.stdout2
-rw-r--r--testsuite/tests/ghci/prog006/prog006.stderr7
-rw-r--r--testsuite/tests/parser/should_compile/T15457.hs12
-rw-r--r--testsuite/tests/parser/should_compile/T15675.hs13
-rw-r--r--testsuite/tests/parser/should_compile/all.T2
-rw-r--r--testsuite/tests/parser/should_fail/T3811b.stderr5
-rw-r--r--testsuite/tests/parser/should_fail/T3811c.stderr8
-rw-r--r--testsuite/tests/parser/should_fail/T3811f.stderr5
-rw-r--r--testsuite/tests/parser/should_fail/all.T4
-rw-r--r--testsuite/tests/parser/should_fail/strictnessDataCon_A.hs1
-rw-r--r--testsuite/tests/parser/should_fail/strictnessDataCon_A.stderr3
-rw-r--r--testsuite/tests/parser/should_fail/strictnessDataCon_B.hs1
-rw-r--r--testsuite/tests/parser/should_fail/strictnessDataCon_B.stderr3
-rw-r--r--testsuite/tests/parser/should_fail/typeopsDataCon_A.hs1
-rw-r--r--testsuite/tests/parser/should_fail/typeopsDataCon_A.stderr4
-rw-r--r--testsuite/tests/parser/should_fail/typeopsDataCon_B.hs1
-rw-r--r--testsuite/tests/parser/should_fail/typeopsDataCon_B.stderr2
-rw-r--r--testsuite/tests/rename/should_fail/rnfail053.stderr7
-rw-r--r--testsuite/tests/typecheck/should_fail/T14761a.stderr10
-rw-r--r--testsuite/tests/typecheck/should_fail/T14761b.stderr10
-rw-r--r--testsuite/tests/typecheck/should_fail/T7210.stderr10
-rw-r--r--testsuite/tests/typecheck/should_fail/T9634.stderr5
22 files changed, 81 insertions, 35 deletions
diff --git a/testsuite/tests/ghc-api/annotations/T11321.stdout b/testsuite/tests/ghc-api/annotations/T11321.stdout
index d4df67dfe5..26fda8b869 100644
--- a/testsuite/tests/ghc-api/annotations/T11321.stdout
+++ b/testsuite/tests/ghc-api/annotations/T11321.stdout
@@ -15,7 +15,6 @@
((Test11321.hs:12:20-29,AnnOpenP), [Test11321.hs:12:20]),
((Test11321.hs:12:26-28,AnnCloseS), [Test11321.hs:12:28]),
((Test11321.hs:12:26-28,AnnOpenS), [Test11321.hs:12:26]),
-((Test11321.hs:13:5-11,AnnTilde), [Test11321.hs:13:7]),
((Test11321.hs:(13,5)-(14,8),AnnDarrow), [Test11321.hs:13:13-14]),
((Test11321.hs:(13,5)-(14,8),AnnVbar), [Test11321.hs:15:3]),
((Test11321.hs:13:9-11,AnnCloseS), [Test11321.hs:13:11]),
@@ -32,7 +31,6 @@
((Test11321.hs:16:12-21,AnnOpenP), [Test11321.hs:16:12]),
((Test11321.hs:16:18-20,AnnCloseS), [Test11321.hs:16:20]),
((Test11321.hs:16:18-20,AnnOpenS), [Test11321.hs:16:18]),
-((Test11321.hs:16:24-34,AnnTilde), [Test11321.hs:16:26]),
((Test11321.hs:16:28-30,AnnCloseP), [Test11321.hs:16:30]),
((Test11321.hs:16:28-30,AnnOpenP), [Test11321.hs:16:28]),
((Test11321.hs:16:28-30,AnnVal), [Test11321.hs:16:29]),
diff --git a/testsuite/tests/ghci/prog006/prog006.stderr b/testsuite/tests/ghci/prog006/prog006.stderr
index 7bc3b1b2ef..d4a37124bc 100644
--- a/testsuite/tests/ghci/prog006/prog006.stderr
+++ b/testsuite/tests/ghci/prog006/prog006.stderr
@@ -1,4 +1,5 @@
-Boot.hs:5:13:
- Not a data constructor: ‘forall’
- Perhaps you intended to use ExistentialQuantification
+Boot.hs:5:21: error:
+ Illegal symbol '.' in type
+ Perhaps you intended to use RankNTypes or a similar language
+ extension to enable explicit-forall syntax: forall <tvs>. <type>
diff --git a/testsuite/tests/parser/should_compile/T15457.hs b/testsuite/tests/parser/should_compile/T15457.hs
new file mode 100644
index 0000000000..7ce80fea1c
--- /dev/null
+++ b/testsuite/tests/parser/should_compile/T15457.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE TypeOperators #-}
+module T15457 where
+
+import Data.Type.Equality
+
+data a ! b; infix 0 !
+data a + b; infix 9 +
+
+fixityProof :: (Int ! Int + Int) :~: (Int ! (Int + Int))
+fixityProof = Refl
+
+data Foo a b = MkFoo (a ! b) !Int !(Bool ! Bool)
diff --git a/testsuite/tests/parser/should_compile/T15675.hs b/testsuite/tests/parser/should_compile/T15675.hs
new file mode 100644
index 0000000000..f5fe410370
--- /dev/null
+++ b/testsuite/tests/parser/should_compile/T15675.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE TypeOperators, MultiParamTypeClasses, ExistentialQuantification #-}
+
+module T15675 where
+
+class a + b
+
+data D1 = forall a b. (a + b) => D1 a b
+data D2 = forall a b. a + b => D2 a b
+
+class a ! b
+
+data D3 = forall a b. (a ! b) => D3 !a !b
+data D4 = forall a b. a ! b => D4 !a !b
diff --git a/testsuite/tests/parser/should_compile/all.T b/testsuite/tests/parser/should_compile/all.T
index d949f2b42e..50fa1a71e7 100644
--- a/testsuite/tests/parser/should_compile/all.T
+++ b/testsuite/tests/parser/should_compile/all.T
@@ -130,3 +130,5 @@ def only_MG_loc(x):
if mg.strip().startswith("(MG"))
return '\n'.join(mgLocs)
test('T15279', normalise_errmsg_fun(only_MG_loc), compile, [''])
+test('T15457', normal, compile, [''])
+test('T15675', normal, compile, [''])
diff --git a/testsuite/tests/parser/should_fail/T3811b.stderr b/testsuite/tests/parser/should_fail/T3811b.stderr
index e2360b23ef..f4e44c603c 100644
--- a/testsuite/tests/parser/should_fail/T3811b.stderr
+++ b/testsuite/tests/parser/should_fail/T3811b.stderr
@@ -1,3 +1,4 @@
-T3811b.hs:4:14:
- Cannot parse data constructor in a data/newtype declaration: !B
+T3811b.hs:4:14: error:
+ Cannot parse data constructor in a data/newtype declaration:
+ ! B
diff --git a/testsuite/tests/parser/should_fail/T3811c.stderr b/testsuite/tests/parser/should_fail/T3811c.stderr
index dd219184e7..431318e268 100644
--- a/testsuite/tests/parser/should_fail/T3811c.stderr
+++ b/testsuite/tests/parser/should_fail/T3811c.stderr
@@ -1,5 +1,5 @@
-T3811c.hs:6:10: error:
- • Unexpected strictness annotation: !Show
- strictness annotation cannot appear nested inside a type
- • In the instance declaration for ‘!Show D’
+T3811c.hs:6:11: error:
+ Strictness annotation applied to a compound type.
+ Did you mean to add parentheses?
+ !(Show D)
diff --git a/testsuite/tests/parser/should_fail/T3811f.stderr b/testsuite/tests/parser/should_fail/T3811f.stderr
index 882ae06706..2d31fa86cf 100644
--- a/testsuite/tests/parser/should_fail/T3811f.stderr
+++ b/testsuite/tests/parser/should_fail/T3811f.stderr
@@ -1,2 +1,5 @@
-T3811f.hs:4:7: Malformed head of type or class declaration: !Foo a
+T3811f.hs:4:8: error:
+ Strictness annotation applied to a compound type.
+ Did you mean to add parentheses?
+ !(Foo a)
diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T
index 960144c9cb..1ae1abb709 100644
--- a/testsuite/tests/parser/should_fail/all.T
+++ b/testsuite/tests/parser/should_fail/all.T
@@ -129,3 +129,7 @@ test('typeops_B', normal, compile_fail, [''])
test('typeops_C', normal, compile_fail, [''])
test('typeops_D', normal, compile_fail, [''])
test('T15053', normal, compile_fail, [''])
+test('typeopsDataCon_A', normal, compile_fail, [''])
+test('typeopsDataCon_B', normal, compile_fail, [''])
+test('strictnessDataCon_A', normal, compile_fail, [''])
+test('strictnessDataCon_B', normal, compile_fail, [''])
diff --git a/testsuite/tests/parser/should_fail/strictnessDataCon_A.hs b/testsuite/tests/parser/should_fail/strictnessDataCon_A.hs
new file mode 100644
index 0000000000..43851c9b27
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/strictnessDataCon_A.hs
@@ -0,0 +1 @@
+type T = MkT { a :: ! + Int }
diff --git a/testsuite/tests/parser/should_fail/strictnessDataCon_A.stderr b/testsuite/tests/parser/should_fail/strictnessDataCon_A.stderr
new file mode 100644
index 0000000000..99d1eb88ec
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/strictnessDataCon_A.stderr
@@ -0,0 +1,3 @@
+
+strictnessDataCon_A.hs:1:21: error:
+ Strictness annotation cannot appear in this position.
diff --git a/testsuite/tests/parser/should_fail/strictnessDataCon_B.hs b/testsuite/tests/parser/should_fail/strictnessDataCon_B.hs
new file mode 100644
index 0000000000..58ba137bee
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/strictnessDataCon_B.hs
@@ -0,0 +1 @@
+type T = MkT { a :: {-# UNPACK #-} + Int }
diff --git a/testsuite/tests/parser/should_fail/strictnessDataCon_B.stderr b/testsuite/tests/parser/should_fail/strictnessDataCon_B.stderr
new file mode 100644
index 0000000000..7b5e239a53
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/strictnessDataCon_B.stderr
@@ -0,0 +1,3 @@
+
+strictnessDataCon_B.hs:1:21: error:
+ {-# UNPACK #-} cannot appear in this position.
diff --git a/testsuite/tests/parser/should_fail/typeopsDataCon_A.hs b/testsuite/tests/parser/should_fail/typeopsDataCon_A.hs
new file mode 100644
index 0000000000..e334c2d1bb
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/typeopsDataCon_A.hs
@@ -0,0 +1 @@
+data T = Int :+ Int :+ Int
diff --git a/testsuite/tests/parser/should_fail/typeopsDataCon_A.stderr b/testsuite/tests/parser/should_fail/typeopsDataCon_A.stderr
new file mode 100644
index 0000000000..a4f089654e
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/typeopsDataCon_A.stderr
@@ -0,0 +1,4 @@
+
+typeopsDataCon_A.hs:1:10: error:
+ Cannot parse an infix data constructor in a data/newtype declaration:
+ Int :+ Int :+ Int
diff --git a/testsuite/tests/parser/should_fail/typeopsDataCon_B.hs b/testsuite/tests/parser/should_fail/typeopsDataCon_B.hs
new file mode 100644
index 0000000000..aa85c2e645
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/typeopsDataCon_B.hs
@@ -0,0 +1 @@
+data T = Int + Int
diff --git a/testsuite/tests/parser/should_fail/typeopsDataCon_B.stderr b/testsuite/tests/parser/should_fail/typeopsDataCon_B.stderr
new file mode 100644
index 0000000000..16dd0a8d0b
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/typeopsDataCon_B.stderr
@@ -0,0 +1,2 @@
+
+typeopsDataCon_B.hs:1:14: error: Not a data constructor: ‘+’
diff --git a/testsuite/tests/rename/should_fail/rnfail053.stderr b/testsuite/tests/rename/should_fail/rnfail053.stderr
index a6d88d2a42..0376517c30 100644
--- a/testsuite/tests/rename/should_fail/rnfail053.stderr
+++ b/testsuite/tests/rename/should_fail/rnfail053.stderr
@@ -1,4 +1,5 @@
-rnfail053.hs:5:10:
- Not a data constructor: ‘forall’
- Perhaps you intended to use ExistentialQuantification
+rnfail053.hs:5:18: error:
+ Illegal symbol '.' in type
+ Perhaps you intended to use RankNTypes or a similar language
+ extension to enable explicit-forall syntax: forall <tvs>. <type>
diff --git a/testsuite/tests/typecheck/should_fail/T14761a.stderr b/testsuite/tests/typecheck/should_fail/T14761a.stderr
index 8eb4580db4..e0e437e934 100644
--- a/testsuite/tests/typecheck/should_fail/T14761a.stderr
+++ b/testsuite/tests/typecheck/should_fail/T14761a.stderr
@@ -1,7 +1,5 @@
-T14761a.hs:3:19:
- Unexpected UNPACK annotation: {-# UNPACK #-}Maybe
- UNPACK annotation cannot appear nested inside a type
- In the type ‘{-# UNPACK #-}Maybe Int’
- In the definition of data constructor ‘A’
- In the data declaration for ‘A’
+T14761a.hs:3:34: error:
+ {-# UNPACK #-} applied to a compound type.
+ Did you mean to add parentheses?
+ {-# UNPACK #-} (Maybe Int)
diff --git a/testsuite/tests/typecheck/should_fail/T14761b.stderr b/testsuite/tests/typecheck/should_fail/T14761b.stderr
index 8357187928..08a319cde3 100644
--- a/testsuite/tests/typecheck/should_fail/T14761b.stderr
+++ b/testsuite/tests/typecheck/should_fail/T14761b.stderr
@@ -1,7 +1,5 @@
-T14761b.hs:5:19:
- Unexpected strictness annotation: !Maybe
- strictness annotation cannot appear nested inside a type
- In the type ‘!Maybe Int’
- In the definition of data constructor ‘A’
- In the data declaration for ‘A’
+T14761b.hs:5:21: error:
+ Strictness annotation applied to a compound type.
+ Did you mean to add parentheses?
+ !(Maybe Int)
diff --git a/testsuite/tests/typecheck/should_fail/T7210.stderr b/testsuite/tests/typecheck/should_fail/T7210.stderr
index 314ffa70e7..4d7cb38a4d 100644
--- a/testsuite/tests/typecheck/should_fail/T7210.stderr
+++ b/testsuite/tests/typecheck/should_fail/T7210.stderr
@@ -1,7 +1,5 @@
-T7210.hs:5:19:
- Unexpected strictness annotation: !IntMap
- strictness annotation cannot appear nested inside a type
- In the type ‘!IntMap Int’
- In the definition of data constructor ‘C’
- In the data declaration for ‘T’
+T7210.hs:5:20: error:
+ Strictness annotation applied to a compound type.
+ Did you mean to add parentheses?
+ !(IntMap Int)
diff --git a/testsuite/tests/typecheck/should_fail/T9634.stderr b/testsuite/tests/typecheck/should_fail/T9634.stderr
index 1a2ed05ef1..8bb1007988 100644
--- a/testsuite/tests/typecheck/should_fail/T9634.stderr
+++ b/testsuite/tests/typecheck/should_fail/T9634.stderr
@@ -1,3 +1,4 @@
-T9634.hs:3:10:
- Cannot parse data constructor in a data/newtype declaration: 1
+T9634.hs:3:10: error:
+ Cannot parse data constructor in a data/newtype declaration:
+ 1