summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2018-05-08 12:24:26 -0700
committerBen Gamari <ben@smart-cactus.org>2018-05-30 22:05:37 -0400
commitb57a54f6be600541dbcc4d8489c751a17a85bec0 (patch)
treee55fa18e6b06947612b74d8062b14b19fe7c4f12
parent730781b42a003604cfa047a02280757a07b09581 (diff)
downloadhaskell-b57a54f6be600541dbcc4d8489c751a17a85bec0.tar.gz
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.
-rw-r--r--compiler/rename/RnBinds.hs15
1 files changed, 11 insertions, 4 deletions
diff --git a/compiler/rename/RnBinds.hs b/compiler/rename/RnBinds.hs
index d7790ca419..79b55029a1 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