summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/rename/RnBinds.lhs13
1 files changed, 11 insertions, 2 deletions
diff --git a/compiler/rename/RnBinds.lhs b/compiler/rename/RnBinds.lhs
index 65df7ba196..75c49437c0 100644
--- a/compiler/rename/RnBinds.lhs
+++ b/compiler/rename/RnBinds.lhs
@@ -454,9 +454,18 @@ rnBind _ (L loc bind@(PatBind { pat_lhs = pat
-- MonoLocalBinds test in TcBinds.decideGeneralisationPlan
bndrs = collectPatBinders pat
bind' = bind { pat_rhs = grhss', bind_fvs = fvs' }
-
+ is_wild_pat = case pat of
+ L _ (WildPat {}) -> True
+ _ -> False
+
+ -- Warn if the pattern binds no variables, except for the
+ -- entirely-explicit idiom _ = rhs
+ -- which (a) is not that different from _v = rhs
+ -- (b) is sometimes used to give a type sig for,
+ -- or an occurrence of, a variable on the RHS
; ifWOptM Opt_WarnUnusedBinds $
- when (null bndrs) (addWarn $ unusedPatBindWarn bind')
+ when (null bndrs && not is_wild_pat) $
+ addWarn $ unusedPatBindWarn bind'
; fvs' `seq` -- See Note [Free-variable space leak]
return (L loc bind', bndrs, all_fvs) }