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

Tony Rogvall <[email protected]>
Newsgroups gmane.comp.lang.erlang.bugs
Message-ID <[email protected]>
On 30 jul 2014, at 11:38, Björn Gustavsson <[email protected]> wrote:

> 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.

Why not just change the error message into:
foo.erl:5 Warning: use of operator =:= (or ==) has no effect 

Or something similar. Not  too complex I guess :-)

/Tony

> 
> 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

"Installing applications can lead to corruption over time. Applications gradually write over each other's libraries, partial upgrades occur, user and system errors happen, and minute changes may be unnoticeable and difficult to fix"

_______________________________________________
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.