[erlang-bugs] bogus 'unsafe variable' warning with try-else

Pierre Fenoll pierrefenoll@REDACTED
Thu Nov 20 14:37:52 CET 2014


I guess the best option (and the one intended by OP) is to file:close/1 as
soon as possible.

Thus Anthony's proposition would be unsuitable (though valid) and OP would
need something like Kostis' case proposition.

I don't get why the scoping rules differ between try…after and case…of. I
don't think they should (but I am surely missing an edge case where the
difference makes sense).


Cheers,
-- 
Pierre Fenoll


On 20 November 2014 14:22, Kostis Sagonas <kostis@REDACTED> wrote:

> On 11/20/14 15:13, Anthony Ramine wrote:
>
>> try file:read(F, 1024 * 1024) of
>>      {ok,Bin} -> binary_to_term(Bin)
>> after
>>      file:close(F)
>> end
>>
>
>
> And the reason to _having_ to write this is?  (*)
>
> Cheers,
> Kostis
>
> (*) Less bugs are exposed in the compiler and less baby cats die in China
> if we all write like that, perhaps? :)
>
> 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.
>
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20141120/2071f333/attachment.htm>


More information about the erlang-bugs mailing list