Commit c68e7e1e authored by Vladislav Zavialov's avatar Vladislav Zavialov Committed by Marge Bot
Browse files

Improve parser error messages for TemplateHaskellQuotes

While [e| |], [t| |], [d| |], and so on, steal syntax from list
comprehensions, [| |] and [|| ||] do not steal any syntax.

Thus we can improve error messages by always accepting them in the
lexer. Turns out the renamer already performs necessary validation.
parent 0fde5377
......@@ -366,15 +366,20 @@ $tab { warnTab }
-- "special" symbols
<0> {
"[|" / { ifExtension ThQuotesBit } { token (ITopenExpQuote NoE NormalSyntax) }
"[||" / { ifExtension ThQuotesBit } { token (ITopenTExpQuote NoE) }
-- Don't check ThQuotesBit here as the renamer can produce a better
-- error message than the lexer (see the thQuotesEnabled check in rnBracket).
"[|" { token (ITopenExpQuote NoE NormalSyntax) }
"[||" { token (ITopenTExpQuote NoE) }
"|]" { token (ITcloseQuote NormalSyntax) }
"||]" { token ITcloseTExpQuote }
-- Check ThQuotesBit here as to not steal syntax.
"[e|" / { ifExtension ThQuotesBit } { token (ITopenExpQuote HasE NormalSyntax) }
"[e||" / { ifExtension ThQuotesBit } { token (ITopenTExpQuote HasE) }
"[p|" / { ifExtension ThQuotesBit } { token ITopenPatQuote }
"[d|" / { ifExtension ThQuotesBit } { layout_token ITopenDecQuote }
"[t|" / { ifExtension ThQuotesBit } { token ITopenTypQuote }
"|]" / { ifExtension ThQuotesBit } { token (ITcloseQuote NormalSyntax) }
"||]" / { ifExtension ThQuotesBit } { token ITcloseTExpQuote }
"[" @varid "|" / { ifExtension QqBit } { lex_quasiquote_tok }
......
module T18251e where
a = [| id |]
T18251e.hs:3:5: error:
• Syntax error on [| id |]
Perhaps you intended to use TemplateHaskell or TemplateHaskellQuotes
• In the Template Haskell quotation [| id |]
......@@ -171,4 +171,5 @@ test('T18251a', normal, compile_fail, [''])
test('T18251b', normal, compile_fail, [''])
test('T18251c', normal, compile_fail, [''])
test('T18251d', normal, compile_fail, [''])
test('T18251e', normal, compile_fail, [''])
test('T18251f', 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