summaryrefslogtreecommitdiff
path: root/testsuite/tests/dependent/should_fail
diff options
context:
space:
mode:
authorRichard Eisenberg <eir@cis.upenn.edu>2016-03-15 14:27:22 -0400
committerRichard Eisenberg <eir@cis.upenn.edu>2016-03-15 21:19:20 -0400
commitaade111248dce0834ed83dc4f18c234967b32024 (patch)
tree6067058be2f2d181d85b6eab2574438f31998559 /testsuite/tests/dependent/should_fail
parent1eefedf7371778d1721d9af9247c2eff12ae7417 (diff)
downloadhaskell-aade111248dce0834ed83dc4f18c234967b32024.tar.gz
Fix #11473.
I've added a check in the zonker for representation polymorphism. I don't like having this be in the zonker, but I don't know where else to put it. It can't go in TcValidity, because a clever enough user could convince the solver to do bogus representation polymorphism even though there's nothing obviously wrong in what they wrote. Note that TcValidity doesn't run over *expressions*, which is where this problem arises. In any case, the check is simple and it works. test case: dependent/should_fail/T11473
Diffstat (limited to 'testsuite/tests/dependent/should_fail')
-rw-r--r--testsuite/tests/dependent/should_fail/T11473.hs27
-rw-r--r--testsuite/tests/dependent/should_fail/T11473.stderr7
-rw-r--r--testsuite/tests/dependent/should_fail/all.T1
3 files changed, 35 insertions, 0 deletions
diff --git a/testsuite/tests/dependent/should_fail/T11473.hs b/testsuite/tests/dependent/should_fail/T11473.hs
new file mode 100644
index 0000000000..12d95caac6
--- /dev/null
+++ b/testsuite/tests/dependent/should_fail/T11473.hs
@@ -0,0 +1,27 @@
+{-# LANGUAGE PolyKinds, TypeFamilies, MagicHash, DataKinds, TypeInType, RankNTypes #-}
+
+module T11473 where
+
+import GHC.Exts
+import GHC.Types
+
+type family Boxed (a :: k) :: *
+type instance Boxed Char# = Char
+type instance Boxed Char = Char
+
+class BoxIt (a :: TYPE lev) where
+ boxed :: a -> Boxed a
+
+instance BoxIt Char# where boxed x = C# x
+instance BoxIt Char where boxed = id
+
+hello :: forall (r :: RuntimeRep). forall (a :: TYPE r). BoxIt a => a -> Boxed a
+hello x = boxed x
+{-# NOINLINE hello #-}
+
+main :: IO ()
+main = do
+ print $ boxed 'c'#
+ print $ boxed 'c'
+ print $ hello 'c'
+ print $ hello 'c'#
diff --git a/testsuite/tests/dependent/should_fail/T11473.stderr b/testsuite/tests/dependent/should_fail/T11473.stderr
new file mode 100644
index 0000000000..7a7cc32871
--- /dev/null
+++ b/testsuite/tests/dependent/should_fail/T11473.stderr
@@ -0,0 +1,7 @@
+
+T11473.hs:19:7: error:
+ The following variable has an unknown runtime representation:
+ Var name: x
+ Var type: a
+ Type's kind: TYPE r
+ Perhaps add a type or kind signature to fix the representation.
diff --git a/testsuite/tests/dependent/should_fail/all.T b/testsuite/tests/dependent/should_fail/all.T
index a90b7bbcdc..c75a9c6a56 100644
--- a/testsuite/tests/dependent/should_fail/all.T
+++ b/testsuite/tests/dependent/should_fail/all.T
@@ -12,3 +12,4 @@ test('T11407', normal, compile_fail, [''])
test('T11334', normal, compile_fail, [''])
test('InferDependency', normal, compile_fail, [''])
test('KindLevelsB', normal, compile_fail, [''])
+test('T11473', normal, compile_fail, [''])