summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Errors
diff options
context:
space:
mode:
authorCarrieMY <carrie.xmy@gmail.com>2022-05-25 16:43:03 +0200
committersheaf <sam.derbyshire@gmail.com>2022-05-25 16:43:03 +0200
commite74fc066cb33e5b7ae0d37cedb30230c597ef1ce (patch)
treecc17cbbe235ada53bdac93e06cbfe4ca632ffa4a /compiler/GHC/Tc/Errors
parent2ff18e390b119c611b3dd429b76cfcbf36ef9545 (diff)
downloadhaskell-wip/T18802.tar.gz
Desugar RecordUpd in `tcExpr`wip/T18802
This patch typechecks record updates by desugaring them inside the typechecker using the HsExpansion mechanism, and then typechecking this desugared result. Example: data T p q = T1 { x :: Int, y :: Bool, z :: Char } | T2 { v :: Char } | T3 { x :: Int } | T4 { p :: Float, y :: Bool, x :: Int } | T5 The record update `e { x=e1, y=e2 }` desugars as follows e { x=e1, y=e2 } ===> let { x' = e1; y' = e2 } in case e of T1 _ _ z -> T1 x' y' z T4 p _ _ -> T4 p y' x' The desugared expression is put into an HsExpansion, and we typecheck that. The full details are given in Note [Record Updates] in GHC.Tc.Gen.Expr. Fixes #2595 #3632 #10808 #10856 #16501 #18311 #18802 #21158 #21289 Updates haddock submodule
Diffstat (limited to 'compiler/GHC/Tc/Errors')
-rw-r--r--compiler/GHC/Tc/Errors/Types.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/GHC/Tc/Errors/Types.hs b/compiler/GHC/Tc/Errors/Types.hs
index 182818616a..e1679d82d0 100644
--- a/compiler/GHC/Tc/Errors/Types.hs
+++ b/compiler/GHC/Tc/Errors/Types.hs
@@ -82,7 +82,7 @@ import GHC.Types.Error
import GHC.Types.Hint (UntickedPromotedThing(..))
import GHC.Types.FieldLabel (FieldLabelString)
import GHC.Types.ForeignCall (CLabelString)
-import GHC.Types.Name (Name, OccName, getSrcLoc)
+import GHC.Types.Name (Name, OccName, getSrcLoc, getSrcSpan)
import GHC.Types.Name.Reader
import GHC.Types.SrcLoc
import GHC.Types.TyThing (TyThing)
@@ -2950,14 +2950,15 @@ pprRelevantBindings :: RelevantBindings -> SDoc
-- This function should be in "GHC.Tc.Errors.Ppr",
-- but's it's here for the moment as it's needed in "GHC.Tc.Errors".
pprRelevantBindings (RelevantBindings bds ran_out_of_fuel) =
- ppUnless (null bds) $
+ ppUnless (null rel_bds) $
hang (text "Relevant bindings include")
- 2 (vcat (map ppr_binding bds) $$ ppWhen ran_out_of_fuel discardMsg)
+ 2 (vcat (map ppr_binding rel_bds) $$ ppWhen ran_out_of_fuel discardMsg)
where
ppr_binding (nm, tidy_ty) =
sep [ pprPrefixOcc nm <+> dcolon <+> ppr tidy_ty
, nest 2 (parens (text "bound at"
<+> ppr (getSrcLoc nm)))]
+ rel_bds = filter (not . isGeneratedSrcSpan . getSrcSpan . fst) bds
discardMsg :: SDoc
discardMsg = text "(Some bindings suppressed;" <+>