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

Tony Rogvall tony@REDACTED
Wed Jul 30 13:41:01 CEST 2014


On 30 jul 2014, at 11:38, Björn Gustavsson <bjorn@REDACTED> wrote:

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

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
> erlang-bugs@REDACTED
> 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"



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20140730/6482f825/attachment.htm>


More information about the erlang-bugs mailing list