summaryrefslogtreecommitdiff
path: root/compiler/parser
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/parser')
-rw-r--r--compiler/parser/Parser.y22
-rw-r--r--compiler/parser/RdrHsSyn.hs16
2 files changed, 21 insertions, 17 deletions
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y
index 21f564e2b9..0d2e90763f 100644
--- a/compiler/parser/Parser.y
+++ b/compiler/parser/Parser.y
@@ -2181,19 +2181,21 @@ docdecld :: { LDocDecl }
decl_no_th :: { LHsDecl RdrName }
: sigdecl { $1 }
- | '!' aexp rhs {% do { let { e = sLL $1 $2 (SectionR (sL1 $1 (HsVar (sL1 $1 bang_RDR))) $2) };
- pat <- checkPattern empty e;
- _ <- ams (sLL $1 $> ())
- (fst $ unLoc $3);
- return $ sLL $1 $> $ ValD $
- PatBind pat (snd $ unLoc $3)
- placeHolderType
- placeHolderNames
- ([],[]) } }
+ | '!' aexp rhs {% do { let { e = sLL $1 $2 (SectionR (sL1 $1 (HsVar (sL1 $1 bang_RDR))) $2)
+ ; l = comb2 $1 $> };
+ (ann, r) <- checkValDef empty SrcStrict e Nothing $3 ;
+ case r of {
+ (FunBind n _ _ _ _) ->
+ ams (L l ()) [mj AnnFunId n] >> return () ;
+ (PatBind (L lh _lhs) _rhs _ _ _) ->
+ ams (L lh ()) [] >> return () } ;
+
+ _ <- ams (L l ()) (ann ++ fst (unLoc $3)) ;
+ return $! (sL l $ ValD r) } }
-- Turn it all into an expression so that
-- checkPattern can check that bangs are enabled
- | infixexp_top opt_sig rhs {% do { (ann,r) <- checkValDef empty $1 (snd $2) $3;
+ | infixexp_top opt_sig rhs {% do { (ann,r) <- checkValDef empty NoSrcStrict $1 (snd $2) $3;
let { l = comb2 $1 $> };
case r of {
(FunBind n _ _ _ _) ->
diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs
index 5b1006ac79..db11287b26 100644
--- a/compiler/parser/RdrHsSyn.hs
+++ b/compiler/parser/RdrHsSyn.hs
@@ -514,9 +514,9 @@ mkPatSynMatchGroup (L loc patsyn_name) (L _ decls) =
wrongNameBindingErr loc decl
; match <- case details of
PrefixCon pats ->
- return $ Match (FunRhs ln Prefix) pats Nothing rhs
+ return $ Match (FunRhs ln Prefix NoSrcStrict) pats Nothing rhs
InfixCon pat1 pat2 ->
- return $ Match (FunRhs ln Infix) [pat1, pat2] Nothing rhs
+ return $ Match (FunRhs ln Infix NoSrcStrict) [pat1, pat2] Nothing rhs
RecCon{} -> recordPatSynErr loc pat
; return $ L loc match }
fromDecl (L loc decl) = extraDeclErr loc decl
@@ -923,25 +923,27 @@ patIsRec e = e == mkUnqual varName (fsLit "rec")
-- Check Equation Syntax
checkValDef :: SDoc
+ -> SrcStrictness
-> LHsExpr RdrName
-> Maybe (LHsType RdrName)
-> Located (a,GRHSs RdrName (LHsExpr RdrName))
-> P ([AddAnn],HsBind RdrName)
-checkValDef msg lhs (Just sig) grhss
+checkValDef msg _strictness lhs (Just sig) grhss
-- x :: ty = rhs parses as a *pattern* binding
= checkPatBind msg (L (combineLocs lhs sig)
(ExprWithTySig lhs (mkLHsSigWcType sig))) grhss
-checkValDef msg lhs opt_sig g@(L l (_,grhss))
+checkValDef msg strictness lhs opt_sig g@(L l (_,grhss))
= do { mb_fun <- isFunLhs lhs
; case mb_fun of
Just (fun, is_infix, pats, ann) ->
- checkFunBind msg ann (getLoc lhs)
+ checkFunBind msg strictness ann (getLoc lhs)
fun is_infix pats opt_sig (L l grhss)
Nothing -> checkPatBind msg lhs g }
checkFunBind :: SDoc
+ -> SrcStrictness
-> [AddAnn]
-> SrcSpan
-> Located RdrName
@@ -950,13 +952,13 @@ checkFunBind :: SDoc
-> Maybe (LHsType RdrName)
-> Located (GRHSs RdrName (LHsExpr RdrName))
-> P ([AddAnn],HsBind RdrName)
-checkFunBind msg ann lhs_loc fun is_infix pats opt_sig (L rhs_span grhss)
+checkFunBind msg strictness ann lhs_loc fun is_infix pats opt_sig (L rhs_span grhss)
= do ps <- checkPatterns msg pats
let match_span = combineSrcSpans lhs_loc rhs_span
-- Add back the annotations stripped from any HsPar values in the lhs
-- mapM_ (\a -> a match_span) ann
return (ann, makeFunBind fun
- [L match_span (Match { m_ctxt = FunRhs fun is_infix
+ [L match_span (Match { m_ctxt = FunRhs fun is_infix strictness
, m_pats = ps
, m_type = opt_sig
, m_grhss = grhss })])