summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Utils/Zonk.hs
diff options
context:
space:
mode:
authorShayne Fletcher <shayne@shaynefletcher.org>2021-02-21 11:48:17 -0500
committerShayne Fletcher <shayne@shaynefletcher.org>2021-03-06 10:21:52 -0500
commit06f1170bed5237766b53306a9ad088e4b151939e (patch)
treec0e141d0ffefcf93a9f9937f72b7d32ce6883699 /compiler/GHC/Tc/Utils/Zonk.hs
parent9e0c0c3a7b6cad8c08e5de7e2a27cf2cb2d2368f (diff)
downloadhaskell-wip/T18599.tar.gz
Record dot syntaxwip/T18599
Diffstat (limited to 'compiler/GHC/Tc/Utils/Zonk.hs')
-rw-r--r--compiler/GHC/Tc/Utils/Zonk.hs28
1 files changed, 19 insertions, 9 deletions
diff --git a/compiler/GHC/Tc/Utils/Zonk.hs b/compiler/GHC/Tc/Utils/Zonk.hs
index 4d4860c7e1..90717063f7 100644
--- a/compiler/GHC/Tc/Utils/Zonk.hs
+++ b/compiler/GHC/Tc/Utils/Zonk.hs
@@ -946,21 +946,31 @@ zonkExpr env expr@(RecordCon { rcon_ext = con_expr, rcon_flds = rbinds })
; return (expr { rcon_ext = new_con_expr
, rcon_flds = new_rbinds }) }
-zonkExpr env (RecordUpd { rupd_flds = rbinds
+-- Record updates via dot syntax are replaced by desugared expressions
+-- in the renamer. See Note [Rebindable Syntax and HsExpansion]. This
+-- is why we match on 'rupd_flds = Left rbinds' here and panic otherwise.
+zonkExpr env (RecordUpd { rupd_flds = Left rbinds
, rupd_expr = expr
- , rupd_ext = RecordUpdTc
- { rupd_cons = cons, rupd_in_tys = in_tys
- , rupd_out_tys = out_tys, rupd_wrap = req_wrap }})
+ , rupd_ext = RecordUpdTc {
+ rupd_cons = cons
+ , rupd_in_tys = in_tys
+ , rupd_out_tys = out_tys
+ , rupd_wrap = req_wrap }})
= do { new_expr <- zonkLExpr env expr
; new_in_tys <- mapM (zonkTcTypeToTypeX env) in_tys
; new_out_tys <- mapM (zonkTcTypeToTypeX env) out_tys
; new_rbinds <- zonkRecUpdFields env rbinds
; (_, new_recwrap) <- zonkCoFn env req_wrap
- ; return (RecordUpd { rupd_expr = new_expr, rupd_flds = new_rbinds
- , rupd_ext = RecordUpdTc
- { rupd_cons = cons, rupd_in_tys = new_in_tys
- , rupd_out_tys = new_out_tys
- , rupd_wrap = new_recwrap }}) }
+ ; return (
+ RecordUpd {
+ rupd_expr = new_expr
+ , rupd_flds = Left new_rbinds
+ , rupd_ext = RecordUpdTc {
+ rupd_cons = cons
+ , rupd_in_tys = new_in_tys
+ , rupd_out_tys = new_out_tys
+ , rupd_wrap = new_recwrap }}) }
+zonkExpr _ (RecordUpd {}) = panic "GHC.Tc.Utils.Zonk: zonkExpr: The impossible happened!"
zonkExpr env (ExprWithTySig _ e ty)
= do { e' <- zonkLExpr env e