Commit e38c07bf authored by Matthew Pickering's avatar Matthew Pickering Committed by Ben Gamari

Improve accuracy of suggestion to use TypeApplications

The suggestion only makes sense when we try
to use an as pattern in an expression context.

It is misleading in the case of a lazy pattern and
view pattern.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1948
parent 6350eb11
......@@ -325,9 +325,10 @@ We return a (bogus) EWildPat in each case.
-}
rnExpr EWildPat = return (hsHoleExpr, emptyFVs) -- "_" is just a hole
rnExpr e@(EAsPat {}) = patSynErr e
rnExpr e@(EViewPat {}) = patSynErr e
rnExpr e@(ELazyPat {}) = patSynErr e
rnExpr e@(EAsPat {}) =
patSynErr e (text "Did you mean to enable TypeApplications?")
rnExpr e@(EViewPat {}) = patSynErr e empty
rnExpr e@(ELazyPat {}) = patSynErr e empty
{-
************************************************************************
......@@ -1854,10 +1855,10 @@ sectionErr expr
= hang (text "A section must be enclosed in parentheses")
2 (text "thus:" <+> (parens (ppr expr)))
patSynErr :: HsExpr RdrName -> RnM (HsExpr Name, FreeVars)
patSynErr e = do { addErr (sep [text "Pattern syntax in expression context:",
patSynErr :: HsExpr RdrName -> SDoc -> RnM (HsExpr Name, FreeVars)
patSynErr e explanation = do { addErr (sep [text "Pattern syntax in expression context:",
nest 4 (ppr e)] $$
text "Did you mean to enable TypeApplications?")
explanation)
; return (EWildPat, emptyFVs) }
badIpBinds :: Outputable a => SDoc -> a -> SDoc
......
mod70.hs:3:8: error:
Pattern syntax in expression context: ~1
Did you mean to enable TypeApplications?
mod70.hs:3:8: error: Pattern syntax in expression context: ~1
......@@ -3,6 +3,4 @@ rnfail016.hs:6:7: error:
Pattern syntax in expression context: x@x
Did you mean to enable TypeApplications?
rnfail016.hs:7:7: error:
Pattern syntax in expression context: ~x
Did you mean to enable TypeApplications?
rnfail016.hs:7:7: error: Pattern syntax in expression context: ~x
rnfail051.hs:7:17: error:
Pattern syntax in expression context: _ -> putStrLn "_"
Did you mean to enable TypeApplications?
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment