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,
-module(foo).
-behaviour(gen_statem).
-export([start_monitor/0,callback_mode/0,init/1,start/3]).
-spec start_monitor() -> {ok, {pid(), reference()}}.
start_monitor() ->
gen_statem:start_monitor(?MODULE, [], []).
callback_mode() ->
state_functions.
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.
Thanks!
--
Matt Kowalczyk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20210124/e5be4b2b/attachment.htm>
-------------- 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: <http://erlang.org/pipermail/erlang-questions/attachments/20210124/e5be4b2b/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 839 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20210124/e5be4b2b/attachment-0001.bin>
More information about the erlang-questions
mailing list