[commit: ghc] wip/T9732: Binding things matched by an unboxed pattern synonym should require a bang (d800e75)
git at git.haskell.org
git at git.haskell.org
Sat Nov 1 04:09:46 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/T9732
Link : http://ghc.haskell.org/trac/ghc/changeset/d800e75294626b134eabb99998863872a415a580/ghc
>---------------------------------------------------------------
commit d800e75294626b134eabb99998863872a415a580
Author: Dr. ERDI Gergo <gergo at erdi.hu>
Date: Sat Nov 1 12:00:19 2014 +0800
Binding things matched by an unboxed pattern synonym should require a bang
>---------------------------------------------------------------
d800e75294626b134eabb99998863872a415a580
testsuite/tests/patsyn/should_compile/all.T | 1 +
testsuite/tests/patsyn/should_compile/unboxed-bind-bang.hs | 10 ++++++++++
testsuite/tests/patsyn/should_fail/all.T | 1 +
testsuite/tests/patsyn/should_fail/unboxed-bind.hs | 10 ++++++++++
testsuite/tests/patsyn/should_fail/unboxed-bind.stderr | 6 ++++++
5 files changed, 28 insertions(+)
diff --git a/testsuite/tests/patsyn/should_compile/all.T b/testsuite/tests/patsyn/should_compile/all.T
index d851bc3..94950a1 100644
--- a/testsuite/tests/patsyn/should_compile/all.T
+++ b/testsuite/tests/patsyn/should_compile/all.T
@@ -10,3 +10,4 @@ test('incomplete', normal, compile, [''])
test('export', normal, compile, [''])
test('T8966', normal, compile, [''])
test('T9023', normal, compile, [''])
+test('unboxed-bind-bang', normal, compile, [''])
diff --git a/testsuite/tests/patsyn/should_compile/unboxed-bind-bang.hs b/testsuite/tests/patsyn/should_compile/unboxed-bind-bang.hs
new file mode 100644
index 0000000..a972b21
--- /dev/null
+++ b/testsuite/tests/patsyn/should_compile/unboxed-bind-bang.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE PatternSynonyms, MagicHash, BangPatterns #-}
+module ShouldCompile where
+
+import GHC.Base
+
+data Foo = MkFoo Int# Int#
+
+pattern P x = MkFoo 0# x
+
+f x = let !(P arg) = x in arg
diff --git a/testsuite/tests/patsyn/should_fail/all.T b/testsuite/tests/patsyn/should_fail/all.T
index bff6bdf..808e261 100644
--- a/testsuite/tests/patsyn/should_fail/all.T
+++ b/testsuite/tests/patsyn/should_fail/all.T
@@ -6,3 +6,4 @@ test('T8961', normal, multimod_compile_fail, ['T8961',''])
test('as-pattern', normal, compile_fail, [''])
test('T9161-1', normal, compile_fail, [''])
test('T9161-2', normal, compile_fail, [''])
+test('unboxed-bind', normal, compile_fail, [''])
diff --git a/testsuite/tests/patsyn/should_fail/unboxed-bind.hs b/testsuite/tests/patsyn/should_fail/unboxed-bind.hs
new file mode 100644
index 0000000..ef1b070
--- /dev/null
+++ b/testsuite/tests/patsyn/should_fail/unboxed-bind.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE PatternSynonyms, MagicHash #-}
+module ShouldFail where
+
+import GHC.Base
+
+data Foo = MkFoo Int# Int#
+
+pattern P x = MkFoo 0# x
+
+f x = let P arg = x in arg
diff --git a/testsuite/tests/patsyn/should_fail/unboxed-bind.stderr b/testsuite/tests/patsyn/should_fail/unboxed-bind.stderr
new file mode 100644
index 0000000..17ca7af
--- /dev/null
+++ b/testsuite/tests/patsyn/should_fail/unboxed-bind.stderr
@@ -0,0 +1,6 @@
+
+unboxed-bind.hs:10:11:
+ Pattern bindings containing unlifted types should use an outermost bang pattern:
+ P arg = x
+ In the expression: let P arg = x in arg
+ In an equation for ‘f’: f x = let P arg = x in arg
More information about the ghc-commits
mailing list