From b28ca38e6e1d75f3c10cc593cdd2ac80ec29690f Mon Sep 17 00:00:00 2001 From: Maciej Bielecki Date: Mon, 2 Jan 2017 17:03:00 -0500 Subject: Don't suggest enabling TypeApplications when it's already enabled Previously when encountering EAsPat in an expression context, TypeApplications was suggested even when already enabled. This patch replaces the suggestion with more appropriate message. Test Plan: validate Reviewers: austin, bgamari, mpickering, goldfire, simonpj Reviewed By: mpickering, goldfire, simonpj Subscribers: simonpj, goldfire, mpickering, thomie Differential Revision: https://phabricator.haskell.org/D2877 GHC Trac Issues: #12879 --- compiler/rename/RnExpr.hs | 10 ++++++++-- testsuite/tests/rename/should_fail/T12879.hs | 4 ++++ testsuite/tests/rename/should_fail/T12879.stderr | 4 ++++ testsuite/tests/rename/should_fail/all.T | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 testsuite/tests/rename/should_fail/T12879.hs create mode 100644 testsuite/tests/rename/should_fail/T12879.stderr diff --git a/compiler/rename/RnExpr.hs b/compiler/rename/RnExpr.hs index 811ecbafbe..17c9042f22 100644 --- a/compiler/rename/RnExpr.hs +++ b/compiler/rename/RnExpr.hs @@ -336,8 +336,14 @@ We return a (bogus) EWildPat in each case. -} rnExpr EWildPat = return (hsHoleExpr, emptyFVs) -- "_" is just a hole -rnExpr e@(EAsPat {}) = - patSynErr e (text "Did you mean to enable TypeApplications?") +rnExpr e@(EAsPat {}) + = do { opt_TypeApplications <- xoptM LangExt.TypeApplications + ; let msg | opt_TypeApplications + = "Type application syntax requires a space before '@'" + | otherwise + = "Did you mean to enable TypeApplications?" + ; patSynErr e (text msg) + } rnExpr e@(EViewPat {}) = patSynErr e empty rnExpr e@(ELazyPat {}) = patSynErr e empty diff --git a/testsuite/tests/rename/should_fail/T12879.hs b/testsuite/tests/rename/should_fail/T12879.hs new file mode 100644 index 0000000000..3f62207f15 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T12879.hs @@ -0,0 +1,4 @@ +{-# LANGUAGE TypeApplications #-} +module ShouldFail where + +f x = x@x diff --git a/testsuite/tests/rename/should_fail/T12879.stderr b/testsuite/tests/rename/should_fail/T12879.stderr new file mode 100644 index 0000000000..1b3559c255 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T12879.stderr @@ -0,0 +1,4 @@ + +T12879.hs:4:7: error: + Pattern syntax in expression context: x@x + Type application syntax requires a space before '@' diff --git a/testsuite/tests/rename/should_fail/all.T b/testsuite/tests/rename/should_fail/all.T index b8c1ac51e5..d42ca5675f 100644 --- a/testsuite/tests/rename/should_fail/all.T +++ b/testsuite/tests/rename/should_fail/all.T @@ -142,3 +142,4 @@ test('T11663', normal, compile_fail, ['']) test('T12229', normal, compile, ['']) test('T12681', normal, multimod_compile_fail, ['T12681','-v0']) test('T12686', normal, compile_fail, ['']) +test('T12879', normal, compile_fail, ['']) -- cgit v1.2.1