I have an erlang OTP application running under version 20. In one of the modules, which is gen_statem, I have a piece of code:
state_bitfield(internal, bitfield, #state{} = State) ->
maybe_send_bitfield(State),
{next_state, state_operate, State}.
maybe_send_bitfield(#state{pieces_info = PiecesInfo} = State) ->
lager:info("Calling have_pieces"),
case have_pieces(PiecesInfo) of
true -> send_bitfield(State);
_ -> lager:info("Not sending bitfield as no pieces.")
end.
have_pieces(PiecesInfo) ->
length([ ok || {Status, _, _} <- PiecesInfo, Status == 3 ]) > 0.
In addition, I use erlang.mk, which defines the parsing for lager, as shown below:
ERLC_COMPILE_OPTS= +'{parse_transform, lager_transform}' +debug_info
ERLC_OPTS += $(ERLC_COMPILE_OPTS)
The code compiles well, but at runtime I get below the error:
22:56:12.454 [error] Lager event handler error_logger_lager_h exited
with reason {'EXIT',{{case_clause,['peer_fsm:4516571b-8f41-4d1b-a9cf-
bf06fc31d54e',
{internal,bitfield},some_term,error,function_clause,state_functions,
[{peer_fsm,'-have_pieces/1-lc$^0/1-0-',[{array,27,0,undefined,
{{{0,undefined,0,[],0},{0,undefined,0,[],0},
{0,undefined,0,...},...},...}}],...},...]]},...}}
I do not understand how the function name becomes changed / converted to "-have_pieces / 1-lc $ ^ 0 / 1-0-", as shown above. Could this be due to some kind of parsing conversion? Any help would be greatly appreciated.