diff options
author | Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> | 2021-07-23 18:21:55 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-07-27 12:03:35 -0400 |
commit | cca08c2ca27881a94e875656fee882b9bf99d145 (patch) | |
tree | f7a861e0034ad5187590b38205a7fd44ec49bcf0 | |
parent | 9bf8d53012be8a36525e0917c67dc4b3deb033ee (diff) | |
download | haskell-cca08c2ca27881a94e875656fee882b9bf99d145.tar.gz |
Parser: suggest TemplateHaskell on $$(...) (#20157)
-rw-r--r-- | compiler/GHC/Parser/Errors/Ppr.hs | 1 | ||||
-rw-r--r-- | testsuite/tests/parser/should_fail/ParserNoTH1.hs | 1 | ||||
-rw-r--r-- | testsuite/tests/parser/should_fail/ParserNoTH1.stderr | 9 | ||||
-rw-r--r-- | testsuite/tests/parser/should_fail/ParserNoTH2.hs | 1 | ||||
-rw-r--r-- | testsuite/tests/parser/should_fail/ParserNoTH2.stderr | 9 | ||||
-rw-r--r-- | testsuite/tests/parser/should_fail/all.T | 2 |
6 files changed, 23 insertions, 0 deletions
diff --git a/compiler/GHC/Parser/Errors/Ppr.hs b/compiler/GHC/Parser/Errors/Ppr.hs index 2cc8b4a113..2a238190c9 100644 --- a/compiler/GHC/Parser/Errors/Ppr.hs +++ b/compiler/GHC/Parser/Errors/Ppr.hs @@ -601,6 +601,7 @@ instance Diagnostic PsMessage where PsErrParse token PsErrParseDetails{..} -> case token of "" -> [] "$" | not ped_th_enabled -> [suggestExtension LangExt.TemplateHaskell] -- #7396 + "$$" | not ped_th_enabled -> [suggestExtension LangExt.TemplateHaskell] -- #20157 "<-" | ped_mdo_in_last_100 -> [suggestExtension LangExt.RecursiveDo] | otherwise -> [SuggestMissingDo] "=" | ped_do_in_last_100 -> [SuggestLetInDo] -- #15849 diff --git a/testsuite/tests/parser/should_fail/ParserNoTH1.hs b/testsuite/tests/parser/should_fail/ParserNoTH1.hs new file mode 100644 index 0000000000..8243afc5e6 --- /dev/null +++ b/testsuite/tests/parser/should_fail/ParserNoTH1.hs @@ -0,0 +1 @@ +f = $(x) -- #7396 diff --git a/testsuite/tests/parser/should_fail/ParserNoTH1.stderr b/testsuite/tests/parser/should_fail/ParserNoTH1.stderr new file mode 100644 index 0000000000..56fffbd525 --- /dev/null +++ b/testsuite/tests/parser/should_fail/ParserNoTH1.stderr @@ -0,0 +1,9 @@ + +ParserNoTH1.hs:1:5: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$’ would denote an untyped splice + were the TemplateHaskell extension enabled. + Suggested fix: Add whitespace after the ‘$’. + +ParserNoTH1.hs:1:5: error: + parse error on input ‘$’ + Suggested fix: Perhaps you intended to use TemplateHaskell diff --git a/testsuite/tests/parser/should_fail/ParserNoTH2.hs b/testsuite/tests/parser/should_fail/ParserNoTH2.hs new file mode 100644 index 0000000000..f27eb2495f --- /dev/null +++ b/testsuite/tests/parser/should_fail/ParserNoTH2.hs @@ -0,0 +1 @@ +f = $$(x) -- #20157 diff --git a/testsuite/tests/parser/should_fail/ParserNoTH2.stderr b/testsuite/tests/parser/should_fail/ParserNoTH2.stderr new file mode 100644 index 0000000000..4f3bba9085 --- /dev/null +++ b/testsuite/tests/parser/should_fail/ParserNoTH2.stderr @@ -0,0 +1,9 @@ + +ParserNoTH2.hs:1:5: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$$’ would denote a typed splice + were the TemplateHaskell extension enabled. + Suggested fix: Add whitespace after the ‘$$’. + +ParserNoTH2.hs:1:5: error: + parse error on input ‘$$’ + Suggested fix: Perhaps you intended to use TemplateHaskell diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T index c288f47c2f..5198d2151d 100644 --- a/testsuite/tests/parser/should_fail/all.T +++ b/testsuite/tests/parser/should_fail/all.T @@ -196,3 +196,5 @@ test('T19923b', normal, compile_fail, ['']) test('T19923c', normal, compile_fail, ['']) test('RecordWildCardsFail', normal, compile_fail, ['']) test('ViewPatternsFail', normal, compile_fail, ['']) +test('ParserNoTH1', normal, compile_fail, ['']) +test('ParserNoTH2', normal, compile_fail, ['']) |