[erlang-bugs] Incorrect scope for a variable

Bengt Kleberg bengt.kleberg@REDACTED
Thu Feb 17 09:08:28 CET 2011


Greetings,

There is a very old feature in Erlang that exports variables from case
statements.


bengt

On Thu, 2011-02-17 at 08:54 +0100, Alexander Demidenko wrote:
> Dear friends!
> 
> Let me explain with an synthetic example.
> 
> Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0]
> [kernel-poll:false]
> Eshell V5.7.5  (abort with ^G)
> 
> 1> {case 1 of X -> X end, case 2 of X -> X; _ -> 4 end}.
> ** exception error: no match of right hand side value 1
> 
> opposite successful example with bit change:
> 2> f().
> ok
> 3> begin X=1, {case 1 of X -> X; _ -> 3 end, case 2 of X -> X; _ -> 4 end} end.
> {1,4}
> 
> In first example, erlang assume X=2 in second 'case' (why?) and trow
> exception before return tuple.
> 
> I'm think this is incorrect behavior. Isn't it?
> 
> --
> ---------------------------------------------
> With best regards,
> Alexander.
> 
> ________________________________________________________________
> erlang-bugs (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-bugs-unsubscribe@REDACTED
> 



More information about the erlang-bugs mailing list