summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2021-12-06 10:13:06 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-12-07 06:29:38 -0500
commit7eb5606441bf11ba2ebd5f8904918dc82a2a3126 (patch)
tree752415cb996eec08cb4314e3f151839ce466a7bb /testsuite
parent5dbdf8781cdf35799e73e270632af6aac8d92e51 (diff)
downloadhaskell-7eb5606441bf11ba2ebd5f8904918dc82a2a3126.tar.gz
More permissive parsing of higher-rank type IPs
The parser now accepts implicit parameters with higher-rank types, such as `foo :: (?ip :: forall a. a -> a) => ...` Before this patch, we instead insisted on parentheses like so: `foo :: (?ip :: (forall a. a -> a)) => ...` The rest of the logic surrounding implicit parameters is unchanged; in particular, even with ImpredicativeTypes, this idiom is not likely to be very useful. Fixes #20654
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/parser/should_fail/T20654a.hs7
-rw-r--r--testsuite/tests/parser/should_fail/T20654a.stderr13
-rw-r--r--testsuite/tests/parser/should_fail/T20654b.hs7
-rw-r--r--testsuite/tests/parser/should_fail/T20654b.stderr4
-rw-r--r--testsuite/tests/parser/should_fail/all.T2
5 files changed, 33 insertions, 0 deletions
diff --git a/testsuite/tests/parser/should_fail/T20654a.hs b/testsuite/tests/parser/should_fail/T20654a.hs
new file mode 100644
index 0000000000..dccabe703f
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T20654a.hs
@@ -0,0 +1,7 @@
+
+{-# LANGUAGE ImplicitParams, ImpredicativeTypes #-}
+
+module T20654a where
+
+foo :: (?poly :: forall a. a -> a) => Int -> Int
+foo x = ?poly x
diff --git a/testsuite/tests/parser/should_fail/T20654a.stderr b/testsuite/tests/parser/should_fail/T20654a.stderr
new file mode 100644
index 0000000000..eb9ed41cd3
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T20654a.stderr
@@ -0,0 +1,13 @@
+
+T20654a.hs:7:9: error:
+ • Couldn't match type: forall a. a -> a
+ with: Int -> Int
+ arising from a functional dependency between constraints:
+ ‘?poly::Int -> Int’
+ arising from a use of implicit parameter ‘?poly’ at T20654a.hs:7:9-13
+ ‘?poly::forall a. a -> a’
+ arising from the type signature for:
+ foo :: (?poly::forall a. a -> a) => Int -> Int at T20654a.hs:6:1-48
+ • In the expression: ?poly
+ In the expression: ?poly x
+ In an equation for ‘foo’: foo x = ?poly x
diff --git a/testsuite/tests/parser/should_fail/T20654b.hs b/testsuite/tests/parser/should_fail/T20654b.hs
new file mode 100644
index 0000000000..54e400fc89
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T20654b.hs
@@ -0,0 +1,7 @@
+
+{-# LANGUAGE ImplicitParams, ImpredicativeTypes #-}
+
+module T20654b where
+
+bar :: (?ip1 :: ?ip2 :: Int) => Int
+bar = ?ip2
diff --git a/testsuite/tests/parser/should_fail/T20654b.stderr b/testsuite/tests/parser/should_fail/T20654b.stderr
new file mode 100644
index 0000000000..ba7f6a356a
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T20654b.stderr
@@ -0,0 +1,4 @@
+
+T20654b.hs:6:17: error:
+ • Expected a type, but ‘?ip2 :: Int’ has kind ‘Constraint’
+ • In the type signature: bar :: (?ip1 :: ?ip2 :: Int) => Int
diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T
index d75e82c032..b3a79e38c4 100644
--- a/testsuite/tests/parser/should_fail/all.T
+++ b/testsuite/tests/parser/should_fail/all.T
@@ -199,3 +199,5 @@ test('ViewPatternsFail', normal, compile_fail, [''])
test('ParserNoTH1', normal, compile_fail, [''])
test('ParserNoTH2', normal, compile_fail, [''])
test('T17865', normal, compile_fail, [''])
+test('T20654a', normal, compile_fail, [''])
+test('T20654b', normal, compile_fail, [''])