summaryrefslogtreecommitdiff
path: root/compiler/GHC/Hs/Expr.hs
diff options
context:
space:
mode:
authorShayne Fletcher <shayne@shaynefletcher.org>2021-04-24 16:59:26 -0400
committerShayne Fletcher <shayne@shaynefletcher.org>2021-05-23 08:02:58 +1000
commit0b1eed74e8ad5194152ed656ac3e4a547726b70a (patch)
tree3e654267d7077050a2358910ebe0ef29cfdddb0d /compiler/GHC/Hs/Expr.hs
parentef4d2999a200f22c864d7c1a2bdfbfd726a0f849 (diff)
downloadhaskell-0b1eed74e8ad5194152ed656ac3e4a547726b70a.tar.gz
Change representation of field selector occurences
- Change the names of the fields in in `data FieldOcc` - Renames `HsRecFld` to `HsRecSel` - Replace `AmbiguousFieldOcc p` in `HsRecSel` with `FieldOcc p` - Contains a haddock submodule update The primary motivation of this change is to remove `AmbiguousFieldOcc`. This is one of a suite of changes improving how record syntax (most notably record update syntax) is represented in the AST.
Diffstat (limited to 'compiler/GHC/Hs/Expr.hs')
-rw-r--r--compiler/GHC/Hs/Expr.hs17
1 files changed, 11 insertions, 6 deletions
diff --git a/compiler/GHC/Hs/Expr.hs b/compiler/GHC/Hs/Expr.hs
index 9b409f4232..a25f90d0b0 100644
--- a/compiler/GHC/Hs/Expr.hs
+++ b/compiler/GHC/Hs/Expr.hs
@@ -218,7 +218,13 @@ data EpAnnUnboundVar = EpAnnUnboundVar
} deriving Data
type instance XVar (GhcPass _) = NoExtField
-type instance XRecFld (GhcPass _) = NoExtField
+
+-- Record selectors at parse time are HsVar; they convert to HsRecSel
+-- on renaming.
+type instance XRecSel GhcPs = Void
+type instance XRecSel GhcRn = NoExtField
+type instance XRecSel GhcTc = NoExtField
+
type instance XLam (GhcPass _) = NoExtField
-- OverLabel not present in GhcTc pass; see GHC.Rename.Expr
@@ -239,7 +245,6 @@ type instance XUnboundVar GhcTc = HoleExprRef
-- Much, much easier just to define HoleExprRef with a Data instance and
-- store the whole structure.
-type instance XRecFld (GhcPass _) = NoExtField
type instance XIPVar (GhcPass _) = EpAnnCO
type instance XOverLitE (GhcPass _) = EpAnnCO
type instance XLitE (GhcPass _) = EpAnnCO
@@ -486,7 +491,7 @@ ppr_expr :: forall p. (OutputableBndrId p)
=> HsExpr (GhcPass p) -> SDoc
ppr_expr (HsVar _ (L _ v)) = pprPrefixOcc v
ppr_expr (HsUnboundVar _ uv) = pprPrefixOcc uv
-ppr_expr (HsRecFld _ f) = pprPrefixOcc f
+ppr_expr (HsRecSel _ f) = pprPrefixOcc f
ppr_expr (HsIPVar _ v) = ppr v
ppr_expr (HsOverLabel _ l) = char '#' <> ppr l
ppr_expr (HsLit _ lit) = ppr lit
@@ -683,7 +688,7 @@ instance Outputable XXExprGhcTc where
ppr_infix_expr :: forall p. (OutputableBndrId p) => HsExpr (GhcPass p) -> Maybe SDoc
ppr_infix_expr (HsVar _ (L _ v)) = Just (pprInfixOcc v)
-ppr_infix_expr (HsRecFld _ f) = Just (pprInfixOcc f)
+ppr_infix_expr (HsRecSel _ f) = Just (pprInfixOcc f)
ppr_infix_expr (HsUnboundVar _ occ) = Just (pprInfixOcc occ)
ppr_infix_expr (XExpr x) = case ghcPass @p of
#if __GLASGOW_HASKELL__ < 901
@@ -786,7 +791,7 @@ hsExprNeedsParens prec = go
go (HsTick _ _ (L _ e)) = go e
go (HsBinTick _ _ _ (L _ e)) = go e
go (RecordCon{}) = False
- go (HsRecFld{}) = False
+ go (HsRecSel{}) = False
go (HsProjection{}) = True
go (HsGetField{}) = False
go (XExpr x) = case ghcPass @p of
@@ -828,7 +833,7 @@ isAtomicHsExpr (HsOverLit {}) = True
isAtomicHsExpr (HsIPVar {}) = True
isAtomicHsExpr (HsOverLabel {}) = True
isAtomicHsExpr (HsUnboundVar {}) = True
-isAtomicHsExpr (HsRecFld{}) = True
+isAtomicHsExpr (HsRecSel{}) = True
isAtomicHsExpr (XExpr x)
| GhcTc <- ghcPass @p = go_x_tc x
| GhcRn <- ghcPass @p = go_x_rn x