[commit: ghc] ghc-8.2: compiler: Do not look up fail in RnExpr if bind pattern is irrefutible. (56a4863)
git at git.haskell.org
git at git.haskell.org
Tue May 16 01:12:05 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.2
Link : http://ghc.haskell.org/trac/ghc/changeset/56a4863b25687319a07db596bd47d724456317a5/ghc
>---------------------------------------------------------------
commit 56a4863b25687319a07db596bd47d724456317a5
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
(cherry picked from commit 2fcb5c5c3f6c5a5936eeb5dc07b476e5737f12ad)
>---------------------------------------------------------------
56a4863b25687319a07db596bd47d724456317a5
compiler/rename/RnExpr.hs | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/compiler/rename/RnExpr.hs b/compiler/rename/RnExpr.hs
index 4e9192c..fe3d308 100644
--- a/compiler/rename/RnExpr.hs
+++ b/compiler/rename/RnExpr.hs
@@ -824,6 +824,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