summaryrefslogtreecommitdiff
path: root/testsuite/tests/patsyn
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2015-12-15 20:50:40 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2015-12-15 20:52:03 +0000
commita701694b27143d094f9de0a78757bbdeaa07daa6 (patch)
treeba0ce8fcf494e99498567e70df2ba2b8d88dd72d /testsuite/tests/patsyn
parent758e6b3a935242acacfa5f1c23ecd1b0e9310e28 (diff)
downloadhaskell-a701694b27143d094f9de0a78757bbdeaa07daa6.tar.gz
Add testcase for #11224
Test Plan: Validate Reviewers: austin, mpickering Reviewed By: mpickering Subscribers: mpickering, thomie Differential Revision: https://phabricator.haskell.org/D1622 GHC Trac Issues: #11224
Diffstat (limited to 'testsuite/tests/patsyn')
-rw-r--r--testsuite/tests/patsyn/should_run/T11224.hs28
-rw-r--r--testsuite/tests/patsyn/should_run/T11224.stdout6
-rw-r--r--testsuite/tests/patsyn/should_run/all.T1
3 files changed, 35 insertions, 0 deletions
diff --git a/testsuite/tests/patsyn/should_run/T11224.hs b/testsuite/tests/patsyn/should_run/T11224.hs
new file mode 100644
index 0000000000..f834e9b47e
--- /dev/null
+++ b/testsuite/tests/patsyn/should_run/T11224.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE PatternSynonyms , ViewPatterns #-}
+
+-- inlining a pattern synonym shouldn't change semantics
+
+import Text.Read
+
+-- pattern PRead :: () => Read a => a -> String
+pattern PRead a <- (readMaybe -> Just a)
+
+foo :: String -> Int
+foo (PRead x) = (x::Int)
+foo (PRead xs) = sum (xs::[Int])
+foo _ = 666
+
+bar :: String -> Int
+bar (readMaybe -> Just x) = (x::Int)
+bar (readMaybe -> Just xs) = sum (xs::[Int])
+bar _ = 666
+
+main :: IO ()
+main = do
+ print $ foo "1" -- 1
+ print $ foo "[1,2,3]" -- 666 -- ???
+ print $ foo "xxx" -- 666
+
+ print $ bar "1" -- 1
+ print $ bar "[1,2,3]" -- 6
+ print $ bar "xxx" -- 666
diff --git a/testsuite/tests/patsyn/should_run/T11224.stdout b/testsuite/tests/patsyn/should_run/T11224.stdout
new file mode 100644
index 0000000000..3a42854357
--- /dev/null
+++ b/testsuite/tests/patsyn/should_run/T11224.stdout
@@ -0,0 +1,6 @@
+1
+6
+666
+1
+6
+666
diff --git a/testsuite/tests/patsyn/should_run/all.T b/testsuite/tests/patsyn/should_run/all.T
index 45c48fbd1f..c12bfc6cb2 100644
--- a/testsuite/tests/patsyn/should_run/all.T
+++ b/testsuite/tests/patsyn/should_run/all.T
@@ -12,3 +12,4 @@ test('match-unboxed', normal, compile_and_run, [''])
test('unboxed-wrapper', normal, compile_and_run, [''])
test('records-run', normal, compile_and_run, [''])
test('ghci', just_ghci, ghci_script, ['ghci.script'])
+test('T11224', [expect_broken(11224)], compile_and_run, ['']) \ No newline at end of file