[erlang-bugs] Funs with duplicate names

Mikael Pettersson mikpelinux@REDACTED
Fri Sep 26 11:26:11 CEST 2014


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.



More information about the erlang-bugs mailing list