Commit 4666be5d authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Don't report unused bindings of the form

       _ = e

Thse are used in a few libraries, either to add type constraints
via a signature, or to mention some variables that are only
otherwise mentioned in one #ifdef branch
parent a0ba88be
......@@ -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) }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment