<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
</head>
<body>
<p>Having a hard time understanding why the following sample code
generates a dialyzer warning,</p>
<p><font face="Courier New, Courier, monospace">-module(foo).<br/>
<br/>
-behaviour(gen_statem).<br/>
<br/>
-export([start_monitor/0,callback_mode/0,init/1,start/3]).<br/>
<br/>
-spec start_monitor() -> {ok, {pid(), reference()}}.<br/>
start_monitor() -><br/>
gen_statem:start_monitor(?MODULE, [], []).<br/>
<br/>
callback_mode() -><br/>
state_functions.<br/>
<br/>
init(_Args) -><br/>
{ok, start, []}.<br/>
<br/>
start(_EventType, _EventContent, Data) -><br/>
{keep_state, Data}.<br/>
</font></p>
<p>The warning is,</p>
<p>foo.erl:7: Invalid type specification for function
foo:start_monitor/0. The success typing is<br/>
() -> 'ignore' | {'error', _}<br/>
</p>
<p>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, <font face="Courier New, Courier, monospace">-spec start_monitor()
-> ignore </font>dialyzer passes successfully.<br/>
<font face="Courier New, Courier, monospace"></font></p>
<p>Thanks!<br/>
</p>
<pre class="moz-signature" cols="72">--
Matt Kowalczyk</pre>
</body></html>