Commit 1e8d1f1c authored by Moritz Kiefer's avatar Moritz Kiefer Committed by thomie

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:
parent c633f71f
......@@ -947,11 +947,14 @@ checkValSig lhs@(L l _) ty
ppr lhs <+> text "::" <+> ppr ty)
$$ text hint)
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
module NoPatternSynonyms where
pattern P :: G Int
NoPatternSynonyms.hs:3:1: error:
Invalid type signature: pattern P :: G Int
Perhaps you meant to use PatternSynonyms?
......@@ -68,6 +68,7 @@ test('T3811e', normal, compile_fail, [''])
test('T3811f', normal, compile_fail, [''])
test('T3811g', normal, compile_fail, [''])
test('NoDoAndIfThenElse', normal, compile_fail, [''])
test('NoPatternSynonyms', normal, compile_fail, [''])
test('NondecreasingIndentationFail', normal, compile_fail, [''])
test('readFailTraditionalRecords1', normal, compile_fail, [''])
test('readFailTraditionalRecords2', normal, compile_fail, [''])
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