diff options
Diffstat (limited to 'compiler/GHC/Parser')
-rw-r--r-- | compiler/GHC/Parser/Errors.hs | 1 | ||||
-rw-r--r-- | compiler/GHC/Parser/Errors/Ppr.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Parser/PostProcess.hs | 9 |
3 files changed, 5 insertions, 7 deletions
diff --git a/compiler/GHC/Parser/Errors.hs b/compiler/GHC/Parser/Errors.hs index 83812f7673..e3f7e869da 100644 --- a/compiler/GHC/Parser/Errors.hs +++ b/compiler/GHC/Parser/Errors.hs @@ -401,7 +401,6 @@ data Hint | SuggestLetInDo | SuggestPatternSynonyms | SuggestInfixBindMaybeAtPat !RdrName - | TypeApplicationsInPatternsOnlyDataCons -- ^ Type applications in patterns are only allowed on data constructors data LexErrKind diff --git a/compiler/GHC/Parser/Errors/Ppr.hs b/compiler/GHC/Parser/Errors/Ppr.hs index 7b9f2e64a0..cf8ae06744 100644 --- a/compiler/GHC/Parser/Errors/Ppr.hs +++ b/compiler/GHC/Parser/Errors/Ppr.hs @@ -616,8 +616,6 @@ pp_hint = \case $$ if opIsAt fun then perhaps_as_pat else empty - TypeApplicationsInPatternsOnlyDataCons -> - text "Type applications in patterns are only allowed on data constructors." perhaps_as_pat :: SDoc perhaps_as_pat = text "Perhaps you meant an as-pattern, which must not be surrounded by whitespace" diff --git a/compiler/GHC/Parser/PostProcess.hs b/compiler/GHC/Parser/PostProcess.hs index 2686bc151b..29deab034a 100644 --- a/compiler/GHC/Parser/PostProcess.hs +++ b/compiler/GHC/Parser/PostProcess.hs @@ -58,6 +58,7 @@ module GHC.Parser.PostProcess ( checkContext, -- HsType -> P HsContext checkPattern, -- HsExp -> P HsPat checkPattern_hints, + checkTyVars, checkMonadComp, -- P (HsStmtContext GhcPs) checkValDef, -- (SrcLoc, HsExp, HsRhs, [HsDecl]) -> P HsDecl checkValSigLhs, @@ -1091,10 +1092,7 @@ checkPat loc (L l e@(PatBuilderVar (L ln c))) tyargs args { pat_con_ext = noAnn -- AZ: where should this come from? , pat_con = L ln c , pat_args = PrefixCon tyargs args - } - | not (null tyargs) = - add_hint TypeApplicationsInPatternsOnlyDataCons $ - patFail (locA l) (ppr e <+> hsep [text "@" <> ppr t | t <- tyargs]) + } | not (null args) && patIsRec c = add_hint SuggestRecursiveDo $ patFail (locA l) (ppr e) @@ -1106,6 +1104,9 @@ checkPat loc (L _ (PatBuilderApp f e)) [] args = do checkPat loc (L l e) [] [] = do p <- checkAPat loc e return (L l p) +checkPat loc e tyargs args + | not (null tyargs), (_:tyargs') <- tyargs = + checkPat loc e tyargs' args checkPat loc e _ _ = patFail (locA loc) (ppr e) checkAPat :: SrcSpanAnnA -> PatBuilder GhcPs -> PV (Pat GhcPs) |