summaryrefslogtreecommitdiff
path: root/compiler/GHC/Rename/Bind.hs
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2023-05-17 13:44:23 -0400
committerBen Gamari <ben@smart-cactus.org>2023-05-17 16:30:54 -0400
commit0190e9fe6f6f5989fbd016881388c20a7fde3bcb (patch)
tree34701dd8040defeb0907558c55843f066f0ba45d /compiler/GHC/Rename/Bind.hs
parent2972fd66f91cb51426a1df86b8166a067015e231 (diff)
downloadhaskell-wip/sand-witch/modern-STV-extension-shuffling.tar.gz
Where introduced 4 new extensions: - PatternSignatures - ExtendedForAllScope - MethodTypeVariables - ImplicitForAll Tasks of ScopedTypeVariables extension were distributed between PatternSignatures, ExtendedForAllScope and MethodTypeVariables according to the proposal. Now ScopedTypeVaribles only implies these three exntesions. Extension ImplicitForAll saves current behavior. NoImplicitForAll disables implicit bounding of type variables in many contexts. Was introduced one new warning option: -Wpattern-signature-binds It warns when pattern signature binds into scope new type variable. For example: f (a :: t) = ...
Diffstat (limited to 'compiler/GHC/Rename/Bind.hs')
-rw-r--r--compiler/GHC/Rename/Bind.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/GHC/Rename/Bind.hs b/compiler/GHC/Rename/Bind.hs
index 73af997a2e..80736c0a34 100644
--- a/compiler/GHC/Rename/Bind.hs
+++ b/compiler/GHC/Rename/Bind.hs
@@ -519,7 +519,7 @@ rnBind sig_fn bind@(FunBind { fun_id = name
-- invariant: no free vars here when it's a FunBind
= do { let plain_name = unLoc name
- ; (matches', rhs_fvs) <- bindSigTyVarsFV (sig_fn plain_name) $
+ ; (matches', rhs_fvs) <- bindSigTyVarsFVExtended (sig_fn plain_name) $
-- bindSigTyVars tests for LangExt.ScopedTyVars
rnMatchGroup (mkPrefixFunRhs name)
rnLExpr matches
@@ -726,7 +726,7 @@ rnPatSynBind sig_fn bind@(PSB { psb_id = L l name
; unless pattern_synonym_ok (addErr TcRnIllegalPatternSynonymDecl)
; let scoped_tvs = sig_fn name
- ; ((pat', details'), fvs1) <- bindSigTyVarsFV scoped_tvs $
+ ; ((pat', details'), fvs1) <- bindSigTyVarsFVExtended scoped_tvs $
rnPat PatSyn pat $ \pat' ->
-- We check the 'RdrName's instead of the 'Name's
-- so that the binding locations are reported
@@ -763,7 +763,7 @@ rnPatSynBind sig_fn bind@(PSB { psb_id = L l name
Unidirectional -> return (Unidirectional, emptyFVs)
ImplicitBidirectional -> return (ImplicitBidirectional, emptyFVs)
ExplicitBidirectional mg ->
- do { (mg', fvs) <- bindSigTyVarsFV scoped_tvs $
+ do { (mg', fvs) <- bindSigTyVarsFVExtended scoped_tvs $
rnMatchGroup (mkPrefixFunRhs (L l name))
rnLExpr mg
; return (ExplicitBidirectional mg', fvs) }
@@ -920,7 +920,8 @@ rnMethodBinds is_cls_decl cls ktv_names binds sigs
-- Rename the bindings RHSs. Again there's an issue about whether the
-- type variables from the class/instance head are in scope.
-- Answer no in Haskell 2010, but yes if you have -XScopedTypeVariables
- ; (binds'', bind_fvs) <- bindSigTyVarsFV ktv_names $
+ -- or -XMethodTypeVariables
+ ; (binds'', bind_fvs) <- bindSigTyVarsFVMethod ktv_names $
do { binds_w_dus <- mapBagM (rnLBind (mkScopedTvFn other_sigs')) binds'
; let bind_fvs = foldr (\(_,_,fv1) fv2 -> fv1 `plusFV` fv2)
emptyFVs binds_w_dus