Commit a701694b authored by Ben Gamari's avatar Ben Gamari Committed by Matthew Pickering

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
parent 758e6b3a
{-# 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
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment