[erlang-bugs] fun_info(F, env) always empty?

Ulf Wiger ulf@REDACTED
Fri Feb 17 18:23:49 CET 2012


Given the following code:
-module(ff).

-export([g/0]).

f() ->
    X = 1, Y = 2,
    fun() ->
	    X-Y
    end.

g() ->
    F = f(),
    erlang:fun_info(F).

If I compile and run it, I get some unexpected results:

Eshell V5.9  (abort with ^G)
1> c(ff).
{ok,ff}
2> ff:g().
[{pid,<0.31.0>},
 {module,ff},
 {new_index,0},
 {new_uniq,<<64,51,168,35,51,43,131,196,64,237,179,79,226,
             167,195,28>>},
 {index,0},
 {uniq,33660225},
 {name,'-f/0-fun-0-'},
 {arity,0},
 {env,[]},
 {type,local}]

According to the documentation, fun_info(F, env) will always be empty for external funs. It *doesn't* say, of course, that it will *not* be empty for other types of fun, but it would seem a reasonable conclusion.

What gives?

BR,
Ulf W




More information about the erlang-bugs mailing list