[erlang-questions] Dialyzer questions

Attila Rajmund Nohl attila.r.nohl@REDACTED
Tue May 3 11:02:01 CEST 2011


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.

> % 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.



More information about the erlang-questions mailing list