diff options
author | Simon Marlow <marlowsd@gmail.com> | 2017-07-03 19:08:30 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-07-03 19:08:31 -0400 |
commit | af403b2eb50abde6a7992470032d7df5faea043e (patch) | |
tree | 8e30d2a65da325173ffe338d81560191fa81e77c /testsuite/tests/ado | |
parent | 8f8d756c5a29217ff79154caa1696b6e572d186f (diff) | |
download | haskell-af403b2eb50abde6a7992470032d7df5faea043e.tar.gz |
ApplicativeDo: document behaviour with strict patterns (#13875)
Test Plan: unit tests, built docs
Reviewers: dfeuer, bgamari, simonpj, austin, erikd
Subscribers: rwbarton, thomie
GHC Trac Issues: #13875, #13242
Differential Revision: https://phabricator.haskell.org/D3691
Diffstat (limited to 'testsuite/tests/ado')
-rw-r--r-- | testsuite/tests/ado/T13242.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/ado/T13242a.hs | 13 | ||||
-rw-r--r-- | testsuite/tests/ado/T13242a.stderr | 47 | ||||
-rw-r--r-- | testsuite/tests/ado/all.T | 1 |
4 files changed, 62 insertions, 1 deletions
diff --git a/testsuite/tests/ado/T13242.hs b/testsuite/tests/ado/T13242.hs index ccaa93c087..2111b85baf 100644 --- a/testsuite/tests/ado/T13242.hs +++ b/testsuite/tests/ado/T13242.hs @@ -1,6 +1,6 @@ --- Panic.hs {-# LANGUAGE ApplicativeDo #-} {-# LANGUAGE ExistentialQuantification #-} +{-# LANGUAGE GADTs #-} module T13242 where import Data.STRef diff --git a/testsuite/tests/ado/T13242a.hs b/testsuite/tests/ado/T13242a.hs new file mode 100644 index 0000000000..540b041fed --- /dev/null +++ b/testsuite/tests/ado/T13242a.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE ApplicativeDo #-} +{-# LANGUAGE ExistentialQuantification #-} +{-# LANGUAGE GADTs #-} +module T13242a where + +data T where A :: forall a . Eq a => a -> T + +test :: IO Bool +test = do + A x <- undefined + _ <- return 'a' + _ <- return 'b' + return (x == x) diff --git a/testsuite/tests/ado/T13242a.stderr b/testsuite/tests/ado/T13242a.stderr new file mode 100644 index 0000000000..dc4564f168 --- /dev/null +++ b/testsuite/tests/ado/T13242a.stderr @@ -0,0 +1,47 @@ + +T13242a.hs:10:5: error: + • Couldn't match expected type ‘a0’ with actual type ‘a’ + because type variable ‘a’ would escape its scope + This (rigid, skolem) type variable is bound by + a pattern with constructor: A :: forall a. Eq a => a -> T, + in a pattern binding in + 'do' block + at T13242a.hs:10:3-5 + • In the expression: + do A x <- undefined + _ <- return 'a' + _ <- return 'b' + return (x == x) + In an equation for ‘test’: + test + = do A x <- undefined + _ <- return 'a' + _ <- return 'b' + return (x == x) + • Relevant bindings include x :: a (bound at T13242a.hs:10:5) + +T13242a.hs:13:11: error: + • Ambiguous type variable ‘a0’ arising from a use of ‘==’ + prevents the constraint ‘(Eq a0)’ from being solved. + Relevant bindings include x :: a0 (bound at T13242a.hs:10:5) + Probable fix: use a type annotation to specify what ‘a0’ should be. + These potential instances exist: + instance Eq Ordering -- Defined in ‘GHC.Classes’ + instance Eq Integer + -- Defined in ‘integer-gmp-1.0.0.1:GHC.Integer.Type’ + instance Eq a => Eq (Maybe a) -- Defined in ‘GHC.Base’ + ...plus 22 others + ...plus five instances involving out-of-scope types + (use -fprint-potential-instances to see them all) + • In a stmt of a 'do' block: return (x == x) + In the expression: + do A x <- undefined + _ <- return 'a' + _ <- return 'b' + return (x == x) + In an equation for ‘test’: + test + = do A x <- undefined + _ <- return 'a' + _ <- return 'b' + return (x == x) diff --git a/testsuite/tests/ado/all.T b/testsuite/tests/ado/all.T index a738c7a6df..bb1cc163d1 100644 --- a/testsuite/tests/ado/all.T +++ b/testsuite/tests/ado/all.T @@ -9,4 +9,5 @@ test('T11607', normal, compile_and_run, ['']) test('ado-optimal', normal, compile_and_run, ['']) test('T12490', normal, compile, ['']) test('T13242', normal, compile, ['']) +test('T13242a', normal, compile_fail, ['']) test('T13875', normal, compile_and_run, ['']) |