Inconsistent unused variable warnings
Summary
- Function-argument bound,
let
bound andwhere
bound variables are treated inconsistently when it comes to unused variable warnings. - Variables appearing on the RHS of a strict binding should be considered "used".
Steps to reproduce
% cat test1.hs && /opt/ghc/bin/ghc-8.10.2 test1.hs
{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -Wall #-}
module Foo where
foo :: a -> ()
foo a = let _ = undefined a b c
b = ()
in ()
where c = ()
bar :: a -> ()
bar a = let !_ = undefined a b c
b = ()
in ()
where c = ()
[1 of 1] Compiling Foo ( test1.hs, test1.o )
test1.hs:9:13: warning: [-Wunused-local-binds]
Defined but not used: ‘b’
|
9 | b = ()
| ^
test1.hs:15:13: warning: [-Wunused-local-binds]
Defined but not used: ‘b’
|
15 | b = ()
| ^
Expected behavior
- For each function there should either be a warning for all of
a
,b
andc
or for none of them. - I would also expect a strict binding to "use" all the variables on its RHS, even if it binds no variables.
Environment
8.10.2 from HVR's Ubuntu PPA