[erlang-questions] gen_statem 20.3 init/1 - {next_event, internal, initial_event}

Peter Morgan peter.james.morgan@REDACTED
Thu Mar 15 12:23:20 CET 2018


Hello -

I am sure I am doing something daft. I picked up 20.3 this morning and have some gen_statem code that previously worked in 20.2.4:

-module(ex1).

-export([callback_mode/0]).
-export([handle_event/4]).
-export([init/1]).
-export([start/0]).

start() ->
    gen_statem:start({local, ?MODULE}, ?MODULE, [], []).

init([]) ->
    {ok,
     initial_state,
     initial_data,
     {next_event, internal, initial_event}}.

callback_mode() ->
    handle_event_function.

handle_event(Type, Event, State, Data) ->
    error_logger:info_report([{type, Type},
                              {event, Event},
                              {state, State},
                              {data, Data}]),
    keep_state_and_data.




brew switch erlang 20.2.4

Erlang/OTP 20 [erts-9.2.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V9.2.1  (abort with ^G)
1> ex1:start().
{ok,<0.62.0>}

=INFO REPORT==== 15-Mar-2018::12:13:29 ===
    type: internal
    event: initial_event
    state: initial_state
    data: initial_data



brew switch erlang 20.3
Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V9.3  (abort with ^G)
1> c(ex1).
{ok,ex1}
2> ex1:start().
{ok,<0.67.0>}
3> 
=ERROR REPORT==== 15-Mar-2018::12:15:02 ===
** State machine ex1 terminating
** Last event = {internal,init_state}
** When server state  = {initial_state,initial_data}
** Reason for termination = error:{bad_action_from_state_function,
                                      {next_events,internal,initial_event}}
** Callback mode = handle_event_function
** Stacktrace =
**  [{gen_statem,parse_actions_next_event,7,
                 [{file,"gen_statem.erl"},{line,1299}]},
     {gen_statem,loop_event_actions_list,10,
                 [{file,"gen_statem.erl"},{line,1194}]},
     {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]


The docs seem to indicate that next_event remains valid on init/1 - http://erlang.org/doc/man/gen_statem.html#type-init_result <http://erlang.org/doc/man/gen_statem.html#type-init_result>.

Thanks
Peter.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180315/8cd3df37/attachment.htm>


More information about the erlang-questions mailing list