diff options
Diffstat (limited to 'compiler/parser/RdrHsSyn.hs')
-rw-r--r-- | compiler/parser/RdrHsSyn.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs index 617f1c08b2..3305e802c1 100644 --- a/compiler/parser/RdrHsSyn.hs +++ b/compiler/parser/RdrHsSyn.hs @@ -1862,6 +1862,9 @@ class b ~ (Body b) GhcPs => DisambECP b where mkHsBangPatPV :: SrcSpan -> Located b -> PV (Located b) -- | Disambiguate tuple sections and unboxed sums mkSumOrTuplePV :: SrcSpan -> Boxity -> SumOrTuple b -> PV (Located b) + -- | Validate infixexp LHS to reject unwanted {-# SCC ... #-} pragmas + rejectPragmaPV :: Located b -> PV () + {- Note [UndecidableSuperClasses for associated types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1952,6 +1955,7 @@ instance p ~ GhcPs => DisambECP (HsCmd p) where mkHsBangPatPV l c = cmdFail l $ text "!" <> ppr c mkSumOrTuplePV l boxity a = cmdFail l (pprSumOrTuple boxity a) + rejectPragmaPV _ = return () cmdFail :: SrcSpan -> SDoc -> PV a cmdFail loc e = addFatalError loc $ @@ -2004,6 +2008,13 @@ instance p ~ GhcPs => DisambECP (HsExpr p) where mkHsBangPatPV l e = patSynErr "Bang pattern" l (text "!" <> ppr e) $ text "Did you mean to add a space after the '!'?" mkSumOrTuplePV = mkSumOrTupleExpr + rejectPragmaPV (L _ (OpApp _ _ _ e)) = + -- assuming left-associative parsing of operators + rejectPragmaPV e + rejectPragmaPV (L l (HsPragE _ prag _)) = + addError l $ + hang (text "A pragma is not allowed in this position:") 2 (ppr prag) + rejectPragmaPV _ = return () patSynErr :: String -> SrcSpan -> SDoc -> SDoc -> PV (LHsExpr GhcPs) patSynErr item l e explanation = @@ -2092,6 +2103,7 @@ instance DisambECP (PatBuilder GhcPs) where hintBangPat l pb return $ L l (PatBuilderPat pb) mkSumOrTuplePV = mkSumOrTuplePat + rejectPragmaPV _ = return () checkUnboxedStringLitPat :: Located (HsLit GhcPs) -> PV () checkUnboxedStringLitPat (L loc lit) = |