Commit 4b1f0721 authored by ruperthorlick's avatar ruperthorlick Committed by Ben Gamari

Add suggestion for PatternSynonyms parse error (fixes #12429)

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D3261
parent 27bf6b68
......@@ -2394,8 +2394,12 @@ srcParseErr options buf len
$$ ppWhen (token == "=")
(text "Perhaps you need a 'let' in a 'do' block?"
$$ text "e.g. 'let x = 5' instead of 'x = 5'")
$$ ppWhen (not ps_enabled && pattern == "pattern") -- #12429
(text "Perhaps you intended to use PatternSynonyms")
where token = lexemeToString (offsetBytes (-len) buf) len
pattern = lexemeToString (offsetBytes (-len - 8) buf) 7
th_enabled = extopt LangExt.TemplateHaskell options
ps_enabled = extopt LangExt.PatternSynonyms options
-- Report a parse failure, giving the span of the previous token as
-- the location of the error. This is the entry point for errors
......
module X where
import Data.Text (pattern Y)
x = 3
testsuite/tests/parser/should_fail/T12429.hs:2:29: error:
parse error on input ‘Y’
Perhaps you intended to use PatternSynonyms
|
2 | import Data.Text (pattern Y)
| ^
......@@ -94,3 +94,4 @@ test('T10196Fail2', normal, compile_fail, [''])
test('T10498a', normal, compile_fail, [''])
test('T10498b', normal, compile_fail, [''])
test('T12051', normal, compile_fail, [''])
test('T12429', 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