diff options
-rw-r--r-- | compiler/parser/RdrHsSyn.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/parser/should_fail/T16999.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/parser/should_fail/T16999.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/parser/should_fail/all.T | 2 |
4 files changed, 13 insertions, 1 deletions
diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs index a574fbe338..defad0fb51 100644 --- a/compiler/parser/RdrHsSyn.hs +++ b/compiler/parser/RdrHsSyn.hs @@ -565,13 +565,15 @@ done. tyConToDataCon :: SrcSpan -> RdrName -> Either (SrcSpan, SDoc) (Located RdrName) tyConToDataCon loc tc | isTcOcc occ || isDataOcc occ - , isLexCon (occNameFS occ) + , isLexCon cs + , cs /= fsLit "->" -- Fixes #16999 = return (cL loc (setRdrNameSpace tc srcDataName)) | otherwise = Left (loc, msg) where occ = rdrNameOcc tc + cs = occNameFS occ msg = text "Not a data constructor:" <+> quotes (ppr tc) mkPatSynMatchGroup :: Located RdrName diff --git a/testsuite/tests/parser/should_fail/T16999.hs b/testsuite/tests/parser/should_fail/T16999.hs new file mode 100644 index 0000000000..d43612d035 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T16999.hs @@ -0,0 +1,6 @@ +module T16999 where + +data Type + = TBool + | TInt + | (->) Type Type diff --git a/testsuite/tests/parser/should_fail/T16999.stderr b/testsuite/tests/parser/should_fail/T16999.stderr new file mode 100644 index 0000000000..f9f1569695 --- /dev/null +++ b/testsuite/tests/parser/should_fail/T16999.stderr @@ -0,0 +1,2 @@ + +T16999.hs:6:5: Not a data constructor: ‘->’ diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T index 2fc7f3d326..5b919e1a2d 100644 --- a/testsuite/tests/parser/should_fail/all.T +++ b/testsuite/tests/parser/should_fail/all.T @@ -161,3 +161,5 @@ test('patFail006', normal, compile_fail, ['']) test('patFail007', normal, compile_fail, ['']) test('patFail008', normal, compile_fail, ['']) test('patFail009', normal, compile_fail, ['']) + +test('T16999', normal, compile_fail, ['']) |