diff options
| author | Moritz Kiefer <moritz.kiefer@purelyfunctional.org> | 2015-10-22 13:40:41 +0200 |
|---|---|---|
| committer | Thomas Miedema <thomasmiedema@gmail.com> | 2015-10-22 13:40:46 +0200 |
| commit | 1e8d1f1c6d85457c786b50b1e054facdb61cbae1 (patch) | |
| tree | 7cae053acab842b3142c35ba29d406cf80f013c6 /compiler/parser | |
| parent | c633f71f9b687dcb9154ffd558442193cbced0e3 (diff) | |
| download | haskell-1e8d1f1c6d85457c786b50b1e054facdb61cbae1.tar.gz | |
Suggest enabling PatternSynonyms (#10943)
Suggest enabling PatternSynonyms if we find an invalid
signature that looks like a pattern synonym.
Reviewed By: austin, thomie
Differential Revision: https://phabricator.haskell.org/D1347
Diffstat (limited to 'compiler/parser')
| -rw-r--r-- | compiler/parser/RdrHsSyn.hs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs index e64a57519d..a1577a767e 100644 --- a/compiler/parser/RdrHsSyn.hs +++ b/compiler/parser/RdrHsSyn.hs @@ -947,11 +947,14 @@ checkValSig lhs@(L l _) ty ppr lhs <+> text "::" <+> ppr ty) $$ text hint) where - hint = if foreign_RDR `looks_like` lhs - then "Perhaps you meant to use ForeignFunctionInterface?" - else if default_RDR `looks_like` lhs - then "Perhaps you meant to use DefaultSignatures?" - else "Should be of form <variable> :: <type>" + hint | foreign_RDR `looks_like` lhs = + "Perhaps you meant to use ForeignFunctionInterface?" + | default_RDR `looks_like` lhs = + "Perhaps you meant to use DefaultSignatures?" + | pattern_RDR `looks_like` lhs = + "Perhaps you meant to use PatternSynonyms?" + | otherwise = + "Should be of form <variable> :: <type>" -- A common error is to forget the ForeignFunctionInterface flag -- so check for that, and suggest. cf Trac #3805 -- Sadly 'foreign import' still barfs 'parse error' because 'import' is a keyword @@ -961,6 +964,7 @@ checkValSig lhs@(L l _) ty foreign_RDR = mkUnqual varName (fsLit "foreign") default_RDR = mkUnqual varName (fsLit "default") + pattern_RDR = mkUnqual varName (fsLit "pattern") checkDoAndIfThenElse :: LHsExpr RdrName |
