[erlang-bugs] Warning shows the wrong operator when useless operator is inside a useless contruction

Björn Gustavsson bjorn@REDACTED
Wed Jul 30 11:38:34 CEST 2014


On Sat, Jul 19, 2014 at 6:11 PM, José Valim
<jose.valim@REDACTED> wrote:
> Given the following code:
>
> -module(foo).
> -compile(export_all).
>
> bar() ->
>   [{foo, hello:world() == bar}],
>   ok.
>
>
> When compiled, it reports:
>
> foo.erl:5: Warning: a term is constructed, but never used
> foo.erl:5: Warning: use of operator '=:=' has no effect

Unfortunately it is not that easy to fix.

The compiler rewrites '==' to '=:=' if
it can know that the result will be the
same ('=:=' is slightly more efficient than
'=='). It does that rewriting before it has
found out that the result of the expression
is not used.

While I can think of a few ways to fix the
problem, they are all more complex than I
would like.

/Bjorn
-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the erlang-bugs mailing list