summaryrefslogtreecommitdiff
path: root/testsuite/tests/rep-poly
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2022-04-07 22:59:56 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-08 13:57:07 -0400
commit23f95735825cd2bfb8d84337cd502d2b2ff533c5 (patch)
tree953e33ebe1b8d2caa30627795c01e533cea003cb /testsuite/tests/rep-poly
parent3415981c36631115bc1d7fb5b51abfcc2932a12f (diff)
downloadhaskell-23f95735825cd2bfb8d84337cd502d2b2ff533c5.tar.gz
Docs: datacon eta-expansion, rep-poly checks
The existing notes weren't very clear on how the eta-expansion of data constructors that occurs in tcInferDataCon/dsConLike interacts with the representation polymorphism invariants. So we explain with a few more details how we ensure that the representation-polymorphic lambdas introduced by tcInferDataCon/dsConLike don't end up causing problems, by checking they are properly instantiated and then relying on the simple optimiser to perform beta reduction. A few additional changes: - ConLikeTc just take type variables instead of binders, as we never actually used the binders. - Removed the FRRApp constructor of FRROrigin; it was no longer used now that we use ExpectedFunTyOrigin. - Adds a bit of documentation to the constructors of ExpectedFunTyOrigin.
Diffstat (limited to 'testsuite/tests/rep-poly')
-rw-r--r--testsuite/tests/rep-poly/RepPolyLambda.hs11
-rw-r--r--testsuite/tests/rep-poly/RepPolyLambda.stderr8
-rw-r--r--testsuite/tests/rep-poly/all.T1
3 files changed, 20 insertions, 0 deletions
diff --git a/testsuite/tests/rep-poly/RepPolyLambda.hs b/testsuite/tests/rep-poly/RepPolyLambda.hs
new file mode 100644
index 0000000000..8164a90fbb
--- /dev/null
+++ b/testsuite/tests/rep-poly/RepPolyLambda.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE PolyKinds #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+
+module RepPolyLambda where
+
+import Data.Kind
+import GHC.Exts
+
+f :: forall r (a :: TYPE r). a -> a
+f = \ x -> x
diff --git a/testsuite/tests/rep-poly/RepPolyLambda.stderr b/testsuite/tests/rep-poly/RepPolyLambda.stderr
new file mode 100644
index 0000000000..d655354548
--- /dev/null
+++ b/testsuite/tests/rep-poly/RepPolyLambda.stderr
@@ -0,0 +1,8 @@
+
+RepPolyLambda.hs:11:5: error:
+ • The binder of the lambda expression
+ does not have a fixed runtime representation.
+ Its type is:
+ a :: TYPE r
+ • In the expression: \ x -> x
+ In an equation for ‘f’: f = \ x -> x
diff --git a/testsuite/tests/rep-poly/all.T b/testsuite/tests/rep-poly/all.T
index e97ae78192..140076e598 100644
--- a/testsuite/tests/rep-poly/all.T
+++ b/testsuite/tests/rep-poly/all.T
@@ -47,6 +47,7 @@ test('RepPolyDoBody1', normal, compile_fail, [''])
test('RepPolyDoBody2', normal, compile_fail, [''])
test('RepPolyDoReturn', normal, compile, [''])
test('RepPolyFFI', normal, compile, [''])
+test('RepPolyLambda', normal, compile_fail, [''])
test('RepPolyLeftSection1', normal, compile, [''])
test('RepPolyLeftSection2', normal, compile_fail, [''])
test('RepPolyMagic', normal, compile_fail, [''])