Re: gen_statem:start_monitor dialyzer warning

Kostis Sagonas <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <[email protected]>
On 1/24/21 2:14 PM, Matt Kowalczyk wrote:
> Having a hard time understanding why the following sample code generates 
> a dialyzer warning,

Either because somebody added wrong specs to 'gen_statem' or forgot to 
update the specs of 'gen'.


===== gen_statem has these types and specs =====

-type start_mon_ret() ::
         {'ok', {pid(),reference()}}
       | 'ignore'
       | {'error', term()}.

-spec start_monitor(
	Module :: module(), Args :: term(), Opts :: [start_opt()]) ->
		   start_mon_ret().
start_monitor(Module, Args, Opts) ->
     gen:start(?MODULE, monitor, Module, Args, Opts).


===== gen:start/5's return type is: ======

-type start_ret()  :: {'ok', pid()} | 'ignore' | {'error', term()}.


Their intersection is: 'ignore' | {'error', term()}.


Dialyzer is never wrong (C), but wrong specs can cause confusion.

Kostis
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.