summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen/should_fail/T13233_elab.hs
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2020-02-03 21:17:11 +0100
committerKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2020-02-04 00:16:40 +0100
commit77cca55cb7f9ffc9ce7f165aeddb93e81a833a41 (patch)
tree12f3c808371d9060c8256793d64c6a9f668b62ee /testsuite/tests/codeGen/should_fail/T13233_elab.hs
parent58ed6c4a0999c0025b1b024bc26171fa6d6773b3 (diff)
downloadhaskell-wip/display-inferred.tar.gz
Always display inferred variables using braceswip/display-inferred
We now always show "forall {a}. T" for inferred variables, previously this was controlled by -fprint-explicit-foralls. This implements part 1 of https://github.com/ghc-proposals/ghc-proposals/pull/179. Part of GHC ticket #16320. Furthermore, when printing a levity restriction error, we now display the HsWrap of the expression. This lets users see the full elaboration with -fprint-typechecker-elaboration (see also #17670)
Diffstat (limited to 'testsuite/tests/codeGen/should_fail/T13233_elab.hs')
-rw-r--r--testsuite/tests/codeGen/should_fail/T13233_elab.hs33
1 files changed, 33 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_fail/T13233_elab.hs b/testsuite/tests/codeGen/should_fail/T13233_elab.hs
new file mode 100644
index 0000000000..87269769d9
--- /dev/null
+++ b/testsuite/tests/codeGen/should_fail/T13233_elab.hs
@@ -0,0 +1,33 @@
+-- Same as T13233, but we compile with -fprint-typechecker-elaboration.
+-- The error message should show an eta-expanded call to (#,#).
+-- See comments at https://gitlab.haskell.org/ghc/ghc/merge_requests/2540
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE PolyKinds #-}
+{-# LANGUAGE UnboxedTuples #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE MagicHash #-}
+module Bug where
+
+import GHC.Exts (TYPE, RuntimeRep, Weak#, State#, RealWorld, mkWeak# )
+
+class Foo (a :: TYPE rep) where
+ bar :: forall rep2 (b :: TYPE rep2). (a -> a -> b) -> a -> a -> b
+
+baz :: forall rep (a :: TYPE rep). Foo a => a -> a -> (# a, a #)
+baz = bar (#,#)
+
+obscure :: (forall (rep1 :: RuntimeRep) (rep2 :: RuntimeRep)
+ (a :: TYPE rep1) (b :: TYPE rep2).
+ a -> b -> (# a, b #)) -> ()
+obscure _ = ()
+
+quux :: ()
+quux = obscure (#,#)
+
+-- It used to be that primops has no binding. However, as described in
+-- Note [Primop wrappers] in PrimOp we now rewrite unsaturated primop
+-- applications to their wrapper, which allows safe use of levity polymorphism.
+primop :: forall (rep :: RuntimeRep) (a :: TYPE rep) b c.
+ a -> b -> (State# RealWorld -> (# State# RealWorld, c #))
+ -> State# RealWorld -> (# State# RealWorld, Weak# b #)
+primop = mkWeak#