[commit: ghc] master: compiler: Do not look up fail in RnExpr if bind pattern is irrefutible. (2fcb5c5)
git at git.haskell.org
git at git.haskell.org
Thu May 11 21:33:34 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/2fcb5c5c3f6c5a5936eeb5dc07b476e5737f12ad/ghc
>---------------------------------------------------------------
commit 2fcb5c5c3f6c5a5936eeb5dc07b476e5737f12ad
Author: Aaron Friel <mayreply at aaronfriel.com>
Date: Thu May 11 15:41:22 2017 -0400
compiler: Do not look up fail in RnExpr if bind pattern is irrefutible.
Adds a check in `rnStmt`, in sub-expr `getFailFunction`, to determine if
the pattern of a bind statement is irrefutible. If so, skip looking up
the `fail` name.
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie
GHC Trac Issues: #13649
Differential Revision: https://phabricator.haskell.org/D3553
>---------------------------------------------------------------
2fcb5c5c3f6c5a5936eeb5dc07b476e5737f12ad
compiler/rename/RnExpr.hs | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/compiler/rename/RnExpr.hs b/compiler/rename/RnExpr.hs
index 154e270..ce22784 100644
--- a/compiler/rename/RnExpr.hs
+++ b/compiler/rename/RnExpr.hs
@@ -833,6 +833,10 @@ rnStmt ctxt rnBody (L loc (BindStmt pat body _ _ _)) thing_inside
; xMonadFailEnabled <- fmap (xopt LangExt.MonadFailDesugaring) getDynFlags
; let getFailFunction
+ -- If the pattern is irrefutible (e.g.: wildcard, tuple,
+ -- ~pat, etc.) we should not need to fail.
+ | isIrrefutableHsPat pat
+ = return (noSyntaxExpr, emptyFVs)
-- For non-monadic contexts (e.g. guard patterns, list
-- comprehensions, etc.) we should not need to fail.
-- See Note [Failing pattern matches in Stmts]
More information about the ghc-commits
mailing list