diff options
author | simonpj@microsoft.com <unknown> | 2008-08-11 12:31:58 +0000 |
---|---|---|
committer | simonpj@microsoft.com <unknown> | 2008-08-11 12:31:58 +0000 |
commit | 27de38efce6d73d2a0209f803cfa98c82773e773 (patch) | |
tree | 77571f73056d624350cf036ea41cebb2dc109715 /compiler/hsSyn | |
parent | 1fa3580c54985d73178d1d396b897176a57cd7f3 (diff) | |
download | haskell-27de38efce6d73d2a0209f803cfa98c82773e773.tar.gz |
Mostly fix Trac #2431: make empty case acceptable to (most of) GHC
See the comments with Trac #2431. This patch makes an empty HsCase
acceptable to the renamer onwards. If you want to accept empty case
in Haskell source there's a little more to do: the ticket lists the
remaining tasks.
Diffstat (limited to 'compiler/hsSyn')
-rw-r--r-- | compiler/hsSyn/HsExpr.lhs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/hsSyn/HsExpr.lhs b/compiler/hsSyn/HsExpr.lhs index e5d85ca08e..bbb2712042 100644 --- a/compiler/hsSyn/HsExpr.lhs +++ b/compiler/hsSyn/HsExpr.lhs @@ -378,8 +378,8 @@ ppr_expr exprType@(HsLam matches) where idType :: HsExpr id -> HsMatchContext id; idType = undefined ppr_expr exprType@(HsCase expr matches) - = sep [ sep [ptext (sLit "case"), nest 4 (ppr expr), ptext (sLit "of")], - nest 2 (pprMatches (CaseAlt `asTypeOf` idType exprType) matches) ] + = sep [ sep [ptext (sLit "case"), nest 4 (ppr expr), ptext (sLit "of {")], + nest 2 (pprMatches (CaseAlt `asTypeOf` idType exprType) matches <+> char '}') ] where idType :: HsExpr id -> HsMatchContext id; idType = undefined ppr_expr (HsIf e1 e2 e3) @@ -663,9 +663,12 @@ data Match id -- Nothing after typechecking (GRHSs id) +isEmptyMatchGroup :: MatchGroup id -> Bool +isEmptyMatchGroup (MatchGroup ms _) = null ms + matchGroupArity :: MatchGroup id -> Arity matchGroupArity (MatchGroup [] _) - = panic "matchGroupArity" -- MatchGroup is never empty + = panic "matchGroupArity" -- Precondition: MatchGroup is non-empty matchGroupArity (MatchGroup (match:matches) _) = ASSERT( all ((== n_pats) . length . hsLMatchPats) matches ) -- Assertion just checks that all the matches have the same number of pats |