it seems that other otp versions have this problem as well
It’s likely because of this. Check this out:
1> Fun = fun(A, B) -> A + B end.
#Fun<erl_eval.41.39164016>
2> Fun2 = fun(A, B) -> A + B end.
#Fun<erl_eval.41.39164016>
3> rp(erlang:fun_info(Fun)).
[{pid,<0.0.0>},
{module,erl_eval},
{new_index,41},
{new_uniq,<<74,179,14,23,76,2,152,184,122,207,206,42,63,
68,21,64>>},
{index,41},
{uniq,39164016},
{name,'-expr/6-fun-4-'},
{arity,2},
{env,[{{1,7},
[],
{eval,#Fun<shell.23.46532814>},
{value,#Fun<shell.5.46532814>},
#{},
[{clause,{1,10},
[{var,{1,11},'A'},{var,{1,14},'B'}],
[],
[{op,{1,22},'+',{var,{1,20},'A'},{var,{1,24},'B'}}]}]}]},
{type,local}]
ok
4> rp(erlang:fun_info(Fun2)).
[{pid,<0.0.0>},
{module,erl_eval},
{new_index,41},
{new_uniq,<<74,179,14,23,76,2,152,184,122,207,206,42,63,
68,21,64>>},
{index,41},
{uniq,39164016},
{name,'-expr/6-fun-4-'},
{arity,2},
{env,[{{1,9},
[],
{eval,#Fun<shell.23.46532814>},
{value,#Fun<shell.5.46532814>},
#{},
[{clause,{1,12},
[{var,{1,13},'A'},{var,{1,16},'B'}],
[],
[{op,{1,24},'+',{var,{1,22},'A'},{var,{1,26},'B'}}]}]}]},
{type,local}]
ok
5>
1 Like
See this old SO post: undefined behavior - Function equality and ordering in Erlang - Stack Overflow
Coming from a LISP/Scheme/Standard ML background, I’d consider it undefined behaviour to compare function closures from different evaluations, regardless of whether they “should” be the same or not. That is, semantic sameness doesn’t imply representational sameness. In this particular case it’s down to an implementation artifact in the Erlang Shell.
thanks
So that’s it