[commit: ghc] master: Add testcase for #11224 (a701694)

git at git.haskell.org git at git.haskell.org
Tue Dec 15 20:51:43 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/a701694b27143d094f9de0a78757bbdeaa07daa6/ghc

>---------------------------------------------------------------

commit a701694b27143d094f9de0a78757bbdeaa07daa6
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Tue Dec 15 20:50:40 2015 +0000

    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


>---------------------------------------------------------------

a701694b27143d094f9de0a78757bbdeaa07daa6
 testsuite/tests/patsyn/should_run/T11224.hs     | 28 +++++++++++++++++++++++++
 testsuite/tests/patsyn/should_run/T11224.stdout |  6 ++++++
 testsuite/tests/patsyn/should_run/all.T         |  1 +
 3 files changed, 35 insertions(+)

diff --git a/testsuite/tests/patsyn/should_run/T11224.hs b/testsuite/tests/patsyn/should_run/T11224.hs
new file mode 100644
index 0000000..f834e9b
--- /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 0000000..3a42854
--- /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 45c48fb..c12bfc6 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



More information about the ghc-commits mailing list