gen_statem:start_monitor dialyzer warning

Matt Kowalczyk matt@REDACTED
Sun Jan 24 14:14:07 CET 2021

Having a hard time understanding why the following sample code generates
a dialyzer warning,




-spec start_monitor() -> {ok, {pid(), reference()}}.
start_monitor() ->
    gen_statem:start_monitor(?MODULE, [], []).

callback_mode() ->

init(_Args) ->
    {ok, start, []}.

start(_EventType, _EventContent, Data) ->
    {keep_state, Data}.

The warning is,

foo.erl:7: Invalid type specification for function foo:start_monitor/0.
The success typing is
          () -> 'ignore' | {'error', _}

What's puzzling me is that this doesn't happen when calling
gen_statem:start or gen_statem:start_link which are also annotated with
the 'ignore' | {'error', _} clauses.  Also, when the spec statement of
foo:start_monitor/0 is changed to, -spec start_monitor() -> ignore
dialyzer passes successfully.


Matt Kowalczyk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: publickey - matt@REDACTED - 2ce7beba.asc
Type: application/pgp-keys
Size: 3060 bytes
Desc: not available
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 839 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the erlang-questions mailing list