summaryrefslogtreecommitdiff
path: root/testsuite/tests/patsyn/should_fail
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2017-03-27 11:24:25 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2017-03-27 11:25:02 +0100
commitd819e416a2a537b78b2698dfe753aa68dfb8b837 (patch)
treee602d2b7efa7ce680284b8e47a7827909204bf0d /testsuite/tests/patsyn/should_fail
parenta6ce7f338c88920f380a2ed3f3f82b0184aeb341 (diff)
downloadhaskell-d819e416a2a537b78b2698dfe753aa68dfb8b837.tar.gz
Only use locally bound variables in pattern synonym declarations
Summary: We were using the unconstrainted `lookupOccRn` function which looked up any variable in scope. Instead we only want to consider variables brought into scope by renaming the pattern on the RHS. A few more changes to make reporting of unbound names suggest the correct things. Fixes #13470 Reviewers: simonpj, austin, bgamari Reviewed By: simonpj Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3377
Diffstat (limited to 'testsuite/tests/patsyn/should_fail')
-rw-r--r--testsuite/tests/patsyn/should_fail/T13470.hs20
-rw-r--r--testsuite/tests/patsyn/should_fail/T13470.stderr8
-rw-r--r--testsuite/tests/patsyn/should_fail/all.T1
3 files changed, 29 insertions, 0 deletions
diff --git a/testsuite/tests/patsyn/should_fail/T13470.hs b/testsuite/tests/patsyn/should_fail/T13470.hs
new file mode 100644
index 0000000000..ec263b9f0a
--- /dev/null
+++ b/testsuite/tests/patsyn/should_fail/T13470.hs
@@ -0,0 +1,20 @@
+{-# Language PatternSynonyms #-}
+module T13470 where
+
+
+-- Used to suggest importing not
+pattern XInstrProxy :: (Bool -> Bool) -> a
+pattern XInstrProxy not <- _
+
+
+-- Used to suggest 'tan' from another module
+pattern P nan <- _
+
+
+
+-- Should suggest the inscope similar variable
+pattern P1 x12345 <- Just x123456
+
+
+-- But not this one
+x1234567 = True
diff --git a/testsuite/tests/patsyn/should_fail/T13470.stderr b/testsuite/tests/patsyn/should_fail/T13470.stderr
new file mode 100644
index 0000000000..748b5d1da2
--- /dev/null
+++ b/testsuite/tests/patsyn/should_fail/T13470.stderr
@@ -0,0 +1,8 @@
+
+T13470.hs:7:21: error: Not in scope: ‘not’
+
+T13470.hs:11:11: error: Not in scope: ‘nan’
+
+T13470.hs:16:12: error:
+ Not in scope: ‘x12345’
+ Perhaps you meant ‘x123456’ (line 16)
diff --git a/testsuite/tests/patsyn/should_fail/all.T b/testsuite/tests/patsyn/should_fail/all.T
index f674a8b258..86ec79a50c 100644
--- a/testsuite/tests/patsyn/should_fail/all.T
+++ b/testsuite/tests/patsyn/should_fail/all.T
@@ -35,3 +35,4 @@ test('T12165', normal, compile_fail, [''])
test('T12819', normal, compile_fail, [''])
test('UnliftedPSBind', normal, compile_fail, [''])
test('T13349', normal, compile_fail, [''])
+test('T13470', normal, compile_fail, [''])