From d819e416a2a537b78b2698dfe753aa68dfb8b837 Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Mon, 27 Mar 2017 11:24:25 +0100 Subject: 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 --- testsuite/tests/patsyn/should_fail/T13470.hs | 20 ++++++++++++++++++++ testsuite/tests/patsyn/should_fail/T13470.stderr | 8 ++++++++ testsuite/tests/patsyn/should_fail/all.T | 1 + 3 files changed, 29 insertions(+) create mode 100644 testsuite/tests/patsyn/should_fail/T13470.hs create mode 100644 testsuite/tests/patsyn/should_fail/T13470.stderr (limited to 'testsuite/tests/patsyn') 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, ['']) -- cgit v1.2.1