Re: Warning shows the wrong operator when useless operator is inside a useless contruction

Björn Gustavsson <[email protected]>
Newsgroups gmane.comp.lang.erlang.bugs
Message-ID <CA+yh78QoPD-+bvvzbJdM3Ms37yn7Z_pck0yTTTENbjJCJGVccQ@mail.gmail.com>
On Sat, Jul 19, 2014 at 6:11 PM, José Valim
<[email protected]> 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
_______________________________________________
erlang-bugs mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-bugs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.