diff --git a/compiler/GHC/Parser/Errors/Ppr.hs b/compiler/GHC/Parser/Errors/Ppr.hs index 2cc8b4a113f1c3174ae08fc9b992f7cca48f0b9e..2a238190c9c690ed6375e66a39f0dbd0f0157d17 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 0000000000000000000000000000000000000000..8243afc5e69ecb028db03038cd9693a8a587cb86 --- /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 0000000000000000000000000000000000000000..56fffbd525a5476a2ab3302a144544f9c57875c3 --- /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 0000000000000000000000000000000000000000..f27eb2495f0824e4f2290b5a3592dd8f71349461 --- /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 0000000000000000000000000000000000000000..4f3bba90853b855e49963879762bf90df0c4aaf5 --- /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 c288f47c2f8952409f8b31a3ce195587f4c5ad73..5198d2151dd9407ef4fa8355c75674d650992d2e 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, [''])