<div dir="ltr"><div><div>The binding {ok,Bin} = file:read(F, 1024*1024) *can* fail. E.g., if I were to load in my own file library, where file:read/2 returns {data,Data}, this fails. And as far as I know, one is not supposed to assume anything about what other modules return during compile time.<br><br></div>Regards<br></div>Joel<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 20, 2014 at 2:22 PM, Kostis Sagonas <span dir="ltr"><<a href="mailto:kostis@cs.ntua.gr" target="_blank">kostis@cs.ntua.gr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 11/20/14 15:13, Anthony Ramine wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
try file:read(F, 1024 * 1024) of<br>
     {ok,Bin} -> binary_to_term(Bin)<br>
after<br>
     file:close(F)<br>
end<br>
</blockquote>
<br>
<br></span>
And the reason to _having_ to write this is?  (*)<br>
<br>
Cheers,<br>
Kostis<br>
<br>
(*) Less bugs are exposed in the compiler and less baby cats die in China if we all write like that, perhaps? :)<br>
<br>
Jokes aside, I also agree the above code is nicer, but that does not mean that the current warning is bogus and the analysis should be fixed.<div class="HOEnZb"><div class="h5"><br>
______________________________<u></u>_________________<br>
erlang-bugs mailing list<br>
<a href="mailto:erlang-bugs@erlang.org" target="_blank">erlang-bugs@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-bugs" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-bugs</a><br>
</div></div></blockquote></div><br></div>