Test Trac #6078
authorSimon Peyton Jones <simonpj@microsoft.com>
Wed, 9 May 2012 16:48:20 +0000 (17:48 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Wed, 9 May 2012 16:48:20 +0000 (17:48 +0100)
testsuite/tests/typecheck/should_fail/T6078.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T6078.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/all.T

diff --git a/testsuite/tests/typecheck/should_fail/T6078.hs b/testsuite/tests/typecheck/should_fail/T6078.hs
new file mode 100644 (file)
index 0000000..4addabe
--- /dev/null
@@ -0,0 +1,11 @@
+{-# LANGUAGE BangPatterns #-}
+module T6078 where
+
+import GHC.Ptr
+import Foreign
+
+byteStringSlice len = \fpbuf ip0 ipe s0 ->
+     let ip1p@(Ptr ip1) = Ptr ip0 `plusPtr` len
+     -- Note that the panic goes away if we use a bang-pattern as follows
+     -- let !ip1p@(Ptr ip1) = Ptr ip0 `plusPtr` len
+     in  ip1p
diff --git a/testsuite/tests/typecheck/should_fail/T6078.stderr b/testsuite/tests/typecheck/should_fail/T6078.stderr
new file mode 100644 (file)
index 0000000..7690ecd
--- /dev/null
@@ -0,0 +1,11 @@
+
+T6078.hs:8:10:
+    You can't mix polymorphic and unlifted bindings
+      ip1p@(Ptr ip1) = Ptr ip0 `plusPtr` len
+      Probable fix: use a bang pattern
+    In the expression:
+      let ip1p@(Ptr ip1) = Ptr ip0 `plusPtr` len in ip1p
+    In the expression:
+      \ fpbuf ip0 ipe s0 -> let ip1p@(Ptr ip1) = ... in ip1p
+    In an equation for `byteStringSlice':
+        byteStringSlice len = \ fpbuf ip0 ipe s0 -> let ... in ip1p
index e9d27ec..e27d0cc 100644 (file)
@@ -276,3 +276,4 @@ test('T5957', normal, compile_fail, [''])
 test('T6001', normal, compile_fail, [''])
 test('T6022', expect_broken(6022), compile_fail, [''])
 test('T5853', normal, compile_fail, [''])
+test('T6078', normal, compile_fail, [''])