gen_statem:start_monitor dialyzer warning

Kostis Sagonas kostis@REDACTED
Sun Jan 24 14:31:54 CET 2021


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


More information about the erlang-questions mailing list