[erlang-bugs] Funs with duplicate names

Anthony Ramine n.oxyde@REDACTED
Fri Sep 26 11:52:31 CEST 2014


That's damn horrible. The bug probably occurs in v3_core given that recursive funs which don't recursive are compiled to plain old functions.

As an aside, I am more and more of the opinion that compilers should proven correct, not tested.

-- 
Anthony Ramine

> Le 26 sept. 2014 à 11:26, Mikael Pettersson <mikpelinux@REDACTED> a écrit :
> 
> Sam Chapin writes:
>> I'm new to the list, apologies if this is known. Discovered while working
>> in OTP 17.1, and it's still present after updating to 17.3.
>> 
>> Create a module containing the following:
>> 
>> f1() -> fun F() -> "f1" end().
>> 
>> f2() -> fun F() -> "f2" end().
>> 
>> Load it and execute f2(). On my system, its return value is "f1".
> 
> I didn't know about this.  Confirmed on my Linux/x86_64 system:
> 
>> cat bug.erl
> -module(bug).
> -compile(export_all).
> f1() -> fun _F() -> "f1" end.
> f2() -> fun _F() -> "f2" end.
>> bin/erl
> Erlang/OTP 17 [erts-6.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
> 
> Eshell V6.2  (abort with ^G)
> 1> c(bug).
> {ok,bug}
> 2> (bug:f2())().
> "f1"
> 3> 
> 
> R16 and R15 can't compile the code.
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs



More information about the erlang-bugs mailing list