diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2015-12-20 23:46:40 +0000 |
---|---|---|
committer | Matthew Pickering <matthewtpickering@gmail.com> | 2015-12-20 23:47:51 +0000 |
commit | 44640af7afa1a01ff2e2357f7c1436b4804866fc (patch) | |
tree | 543508efaff25d1cdef9615078ef66f74ebab529 /testsuite/tests/patsyn | |
parent | 8d954125604e4585167306c4f1d4807275be0a61 (diff) | |
download | haskell-44640af7afa1a01ff2e2357f7c1436b4804866fc.tar.gz |
Allow as-patterns in pattern synonym declarations.
We can allow them if they contain no free variables. This patch just allows
them in one direction and not to be used as builders as the original ticket
suggests.
Test Plan: ./validate
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1666
GHC Trac Issues: #9739
Conflicts:
testsuite/tests/patsyn/should_fail/all.T
Diffstat (limited to 'testsuite/tests/patsyn')
-rw-r--r-- | testsuite/tests/patsyn/should_compile/T9793.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_compile/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/T9793-fail.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/T9793-fail.stderr | 4 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_fail/as-pattern.stderr | 4 |
6 files changed, 19 insertions, 2 deletions
diff --git a/testsuite/tests/patsyn/should_compile/T9793.hs b/testsuite/tests/patsyn/should_compile/T9793.hs new file mode 100644 index 0000000000..230c8618a4 --- /dev/null +++ b/testsuite/tests/patsyn/should_compile/T9793.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE PatternSynonyms #-} +module T9793 where + +pattern P :: [a] -> [a] +pattern P x <- x@(_:_) diff --git a/testsuite/tests/patsyn/should_compile/all.T b/testsuite/tests/patsyn/should_compile/all.T index 7ab5ac7e7c..3793c0d322 100644 --- a/testsuite/tests/patsyn/should_compile/all.T +++ b/testsuite/tests/patsyn/should_compile/all.T @@ -44,3 +44,4 @@ test('export-record-selector', normal, compile, ['']) test('T10897', expect_broken(10897), multi_compile, ['T10897', [ ('T10897a.hs','-c') ,('T10897b.hs', '-c')], '']) +test('T9793', normal, compile, ['']) diff --git a/testsuite/tests/patsyn/should_fail/T9793-fail.hs b/testsuite/tests/patsyn/should_fail/T9793-fail.hs new file mode 100644 index 0000000000..2787a8d6ca --- /dev/null +++ b/testsuite/tests/patsyn/should_fail/T9793-fail.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE PatternSynonyms #-} + +module Foo where + +pattern P :: [a] -> [a] +pattern P x <- x@(y:_) diff --git a/testsuite/tests/patsyn/should_fail/T9793-fail.stderr b/testsuite/tests/patsyn/should_fail/T9793-fail.stderr new file mode 100644 index 0000000000..62713dcd4c --- /dev/null +++ b/testsuite/tests/patsyn/should_fail/T9793-fail.stderr @@ -0,0 +1,4 @@ + +T9793-fail.hs:6:16: error: + Pattern synonym definition cannot contain as-patterns (@) which contain free variables: + x@(y : _) diff --git a/testsuite/tests/patsyn/should_fail/all.T b/testsuite/tests/patsyn/should_fail/all.T index 6ef64ae5ed..6163da1aab 100644 --- a/testsuite/tests/patsyn/should_fail/all.T +++ b/testsuite/tests/patsyn/should_fail/all.T @@ -27,3 +27,4 @@ test('export-type-synonym', normal, compile_fail, ['']) test('export-ps-rec-sel', normal, compile_fail, ['']) test('T11053', normal, compile, ['-fwarn-missing-pat-syn-sigs']) test('T10426', normal, compile_fail, ['']) +test('T9793-fail', normal, compile_fail, ['']) diff --git a/testsuite/tests/patsyn/should_fail/as-pattern.stderr b/testsuite/tests/patsyn/should_fail/as-pattern.stderr index 62db28f023..caabd47090 100644 --- a/testsuite/tests/patsyn/should_fail/as-pattern.stderr +++ b/testsuite/tests/patsyn/should_fail/as-pattern.stderr @@ -1,4 +1,4 @@ -as-pattern.hs:4:18: - Pattern synonym definition cannot contain as-patterns (@): +as-pattern.hs:4:18: error: + Pattern synonym definition cannot contain as-patterns (@) which contain free variables: x@(Just y) |