[erlang-questions] Dialyzer questions

Prashanth Mundkur pmundkur.erlang@REDACTED
Tue May 3 23:24:52 CEST 2011


On 11:02 Tue 03 May     , Attila Rajmund Nohl wrote:
> 2011/5/3, Prashanth Mundkur <pmundkur.erlang@REDACTED>:
> [...]
> > We are trying to understand the following output (I hope the inline code
> > pasting below comes out readable):
> >
> > $ cat dial.erl
> > -module(dial).
> > -export([abort/2, extract/2,
> >          diskspace/1, monitor_diskspace/2, refresh_tags/1,
> > monitor_launch/0]).
> >
> > % We have helper functions like this:
> > abort(Msg, Code) ->
> >     error_logger:warning_report(Msg),
> >     exit(Code).
> > % which give rise to the following dialyzer message:
> > %
> > %   Function abort/2 only terminates with explicit exception
> > % How do we interpret this message?
> 
> As it is written :-) The exit/1 call terminates the process, so the
> function does not return. If this is what you want, you can skip this
> warning.

I discovered that just adding a spec specifying a no_return() makes
the warning go away; that's exactly what I needed.

> > % Even with a plt that includes stdlib, there is no warning for the
> > % following code:
> > -spec extract(binary(), nonempty_string()) -> 'ok'.
> > extract(Pack, Dir) ->
> >     case zip:extract(Pack, [{cwd, Dir}]) of
> >         {ok, Files} ->
> >             Files;
> >         {error, Reason} ->
> >             exit({error, Reason})
> >     end.
> 
> Yes, because at least one clause does return a value.

Yes, but the value it returns is not an 'ok'.

Thanks,

--prashanth



More information about the erlang-questions mailing list