summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2021-07-10 13:28:59 +0200
committersheaf <sam.derbyshire@gmail.com>2021-07-10 13:29:03 +0200
commit901f0e1b38730401a3e74d25a0b041ce551797c9 (patch)
tree297b44cafd28b33dc866360d69ee22b951803c12 /testsuite
parent2d4cdfda6a7f068fe4a1cf586ccb2866b35e0250 (diff)
downloadhaskell-901f0e1b38730401a3e74d25a0b041ce551797c9.tar.gz
Don't return unitExpr in dsWhenNoErrs
- fixes #18149 and #14765 dsWhenNoErrs now returns "runtimeError @ty" when disallowed representation polymorphism is detected, where ty is the type of the result CoreExpr. "ty" is passed as an additional argument to dsWhenNoErrs, and is used only in the case of such an error. The calls to dsWhenNoErrs must now compute the type of the CoreExpr they are trying to build, so that an error of the right type can be used in case of a representation polymorphism failure.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/typecheck/should_fail/T12709.stderr12
-rw-r--r--testsuite/tests/typecheck/should_fail/T14765.hs11
-rw-r--r--testsuite/tests/typecheck/should_fail/T14765.stderr6
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T1
4 files changed, 30 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/T12709.stderr b/testsuite/tests/typecheck/should_fail/T12709.stderr
index f8da5ea120..1d3334c6f7 100644
--- a/testsuite/tests/typecheck/should_fail/T12709.stderr
+++ b/testsuite/tests/typecheck/should_fail/T12709.stderr
@@ -5,6 +5,18 @@ T12709.hs:28:13: error:
Kind: TYPE rep
In the type of expression: 1
+T12709.hs:28:13: error:
+ A representation-polymorphic type is not allowed here:
+ Type: a
+ Kind: TYPE rep
+ In the type of expression: 1 + 2
+
+T12709.hs:28:13: error:
+ A representation-polymorphic type is not allowed here:
+ Type: a
+ Kind: TYPE rep
+ In the type of expression: 1 + 2 + 3
+
T12709.hs:28:17: error:
A representation-polymorphic type is not allowed here:
Type: a
diff --git a/testsuite/tests/typecheck/should_fail/T14765.hs b/testsuite/tests/typecheck/should_fail/T14765.hs
new file mode 100644
index 0000000000..b124252bb4
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T14765.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE Haskell2010 #-}
+{-# LANGUAGE MagicHash, PolyKinds, ExplicitForAll #-}
+
+module T14765 where
+
+import GHC.Exts
+
+fold :: forall rep a (r :: TYPE rep).
+ (r -> a -> Proxy# r -> r) -> (Proxy# r -> r) -> [a] -> r
+fold f k [] = k proxy#
+fold f k (x : xs) = fold f (f (k proxy#) x) xs
diff --git a/testsuite/tests/typecheck/should_fail/T14765.stderr b/testsuite/tests/typecheck/should_fail/T14765.stderr
new file mode 100644
index 0000000000..c837c0d717
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T14765.stderr
@@ -0,0 +1,6 @@
+
+T14765.hs:11:31: error:
+ A representation-polymorphic type is not allowed here:
+ Type: r
+ Kind: TYPE rep
+ In the type of expression: (k proxy#)
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index b776f1d5dd..8745ea9172 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -480,6 +480,7 @@ test('T14607', normal, compile_fail, [''])
test('T14605', normal, compile_fail, [''])
test('T14761a', normal, compile_fail, [''])
test('T14761b', normal, compile_fail, [''])
+test('T14765', normal, compile_fail, [''])
test('T14884', normal, compile_fail, [''])
test('T14904a', normal, compile_fail, [''])
test('T14904b', normal, compile_fail, [''])