[erlang-questions 23] Re: dialyzer and ssl

Kostis Sagonas kostis@REDACTED
Sat Mar 26 13:45:35 CET 2011


Roberto Ostinelli wrote:
> dear list,
> 
> i'm getting this dialyzer warning i cannot understand:
> 
> "The pattern 'ok' can never match the type {'error',_} | 
> {'ok',{'sslsocket',_,_}}"
> 
> this points to line 4 of this code extract:
> 
> 1. case ssl:transport_accept(ListenSocket) of
> 2.    {ok, {sslsocket, _, _} = Sock} ->
> 3.        case ssl:ssl_accept(Sock, 60000) of
> 4.            ok ->
>                 ...
> 5.            {error, _Reason} ->
>                 ...
> 6.        end
> 7.    {error, _Reason} ->
>         ...
> 8. end
> 
> afaik, ssl_accept/2 returns ok | {error, Reason} as per the specs:
> http://www.erlang.org/doc/man/ssl.html#ssl_accept-2
> 
> is this due to some discrepancy in docs/specs? or am i missing something?

You have not told us which Erlang/OTP version this is, so it's hard to 
tell you what's happening. The documentation you are pointing us at is 
for R14B02. Is your code also using the dialyzer of this version?

In R14B02 the spec for this function (from the ssl.erl code) reads:

     -spec ssl_accept(#sslsocket{} | port(), timeout()| [option()]) ->
                  ok | {ok, #sslsocket{}} | {error, reason()}.

which makes me strongly suspect that this function has changed return 
values between Erlang/OTP versions (it was previously returning 'ok' and 
now it returns {'ok', #sslsocket{}}, or the other way around).

My advice: if you are to be relying on the Erlang/OTP documentation on 
the web, use R14B02.

Kostis



More information about the erlang-questions mailing list