summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser/PostProcess.hs
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2020-10-03 19:49:50 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-10-07 15:02:10 -0400
commitd6dff830754a97220eacf032c32cd54b18654917 (patch)
tree6cbe21b946af31e975c602f0bfc12e06cac7eb68 /compiler/GHC/Parser/PostProcess.hs
parent0e8b923d3c8a5ff415091b92c4c7b7e1e33d0ae6 (diff)
downloadhaskell-d6dff830754a97220eacf032c32cd54b18654917.tar.gz
Preserve as-parsed arrow type for HsUnrestrictedArrow
When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791
Diffstat (limited to 'compiler/GHC/Parser/PostProcess.hs')
-rw-r--r--compiler/GHC/Parser/PostProcess.hs10
1 files changed, 1 insertions, 9 deletions
diff --git a/compiler/GHC/Parser/PostProcess.hs b/compiler/GHC/Parser/PostProcess.hs
index 0a90fd8fd0..2fd38dbdba 100644
--- a/compiler/GHC/Parser/PostProcess.hs
+++ b/compiler/GHC/Parser/PostProcess.hs
@@ -631,24 +631,16 @@ mkConDeclH98 name mb_forall mb_cxt args
-- provided), context (if provided), argument types, and result type, and
-- records whether this is a prefix or record GADT constructor. See
-- Note [GADT abstract syntax] in "GHC.Hs.Decls" for more details.
---
--- * If -XLinearTypes is not enabled, the function arrows in a prefix GADT
--- constructor are always interpreted as linear. If -XLinearTypes is enabled,
--- we faithfully record whether -> or %1 -> was used.
mkGadtDecl :: [Located RdrName]
-> LHsType GhcPs
-> P (ConDecl GhcPs)
mkGadtDecl names ty = do
- linearEnabled <- getBit LinearTypesBit
-
let (args, res_ty)
| L _ (HsFunTy _ _w (L loc (HsRecTy _ rf)) res_ty) <- body_ty
= (RecCon (L loc rf), res_ty)
| otherwise
= let (arg_types, res_type) = splitHsFunType body_ty
- arg_types' | linearEnabled = arg_types
- | otherwise = map (hsLinear . hsScaledThing) arg_types
- in (PrefixCon arg_types', res_type)
+ in (PrefixCon arg_types, res_type)
pure $ ConDeclGADT { con_g_ext = noExtField
, con_names = names