[commit: ghc] master: SplicePat's should not trip -Wunused-pattern-binds (b57a54f)
git at git.haskell.org
git at git.haskell.org
Thu May 31 02:06:14 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/b57a54f6be600541dbcc4d8489c751a17a85bec0/ghc
>---------------------------------------------------------------
commit b57a54f6be600541dbcc4d8489c751a17a85bec0
Author: Alec Theriault <alec.theriault at gmail.com>
Date: Tue May 8 12:24:26 2018 -0700
SplicePat's should not trip -Wunused-pattern-binds
The warning does not consider the fact that the splice pattern may
very well end up binding variables.
>---------------------------------------------------------------
b57a54f6be600541dbcc4d8489c751a17a85bec0
compiler/rename/RnBinds.hs | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/compiler/rename/RnBinds.hs b/compiler/rename/RnBinds.hs
index d7790ca..79b5502 100644
--- a/compiler/rename/RnBinds.hs
+++ b/compiler/rename/RnBinds.hs
@@ -470,9 +470,10 @@ rnBind _ bind@(PatBind { pat_lhs = pat
ok_nobind_pat
= -- See Note [Pattern bindings that bind no variables]
case pat of
- L _ (WildPat {}) -> True
- L _ (BangPat {}) -> True -- #9127, #13646
- _ -> False
+ L _ (WildPat {}) -> True
+ L _ (BangPat {}) -> True -- #9127, #13646
+ L _ (SplicePat {}) -> True
+ _ -> False
-- Warn if the pattern binds no variables
-- See Note [Pattern bindings that bind no variables]
@@ -518,7 +519,7 @@ rnBind _ b = pprPanic "rnBind" (ppr b)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Generally, we want to warn about pattern bindings like
Just _ = e
-because they don't do anything! But we have two exceptions:
+because they don't do anything! But we have three exceptions:
* A wildcard pattern
_ = rhs
@@ -532,6 +533,12 @@ because they don't do anything! But we have two exceptions:
Moreover, Trac #13646 argues that even for single constructor
types, you might want to write the constructor. See also #9127.
+* A splice pattern
+ $(th-lhs) = rhs
+ It is impossible to determine whether or not th-lhs really
+ binds any variable. We should disable the warning for any pattern
+ which contain splices, but that is a more expensive check.
+
Note [Free-variable space leak]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We have
More information about the ghc-commits
mailing list