summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite')
-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