[erlang-questions] dialyzer and socket without option 'active'

Kostis Sagonas kostis@REDACTED
Tue Nov 6 09:22:27 CET 2007


Ludovic Coquelle wrote:
> Hi,
> First, thanks for dialyzer contributors: dialyzer find caveat as fast as 
> I write bug :)

Thanks! We know.

We have optimized dialyzer especially for users like you ;-)

> However, it seems to fail to understand this code:
> I open a TCP socket with option [{active, false}, {packet,http}],
> thus I should be able to write something along the line of:
> case gen_tcp:recv(Sock, 0, TO) ->
> {ok, {http_request, M, P, V}} -> ...
> Any -> ...
> end
> 
> The code works, but dialyzer complains that 'case' around gen_tcp:recv 
> can never match {'error',atom()} | {'ok',binary() | 
> possibly_improper_list()}
> ... looks like dialyzer do not understand the non-documented feature 
> (http packet + active false)
> 
> Is it a known behaviour? Am I doing something wrong?

For BIFs that are (mostly) in C, dialyzer has hard-coded information 
about their arguments mainly by taking the corresponding information 
from the OTP documentation. For dialyzer that's the only way to know 
their types.

If I understand you correctly -- it's actually kind of hard without a 
concrete example to test and with the erlang.org site down -- you are 
using options which are not documented.  Since dialyzer knows nothing 
about these options, the only reasonable reaction is to act as if they 
are not allowed (i.e., the call will fail).  Hence the warning.

Since we have no guarantee that the options are "there to stay" we will 
add information about them only when they become official.  Sorry about 
that.

Kostis



More information about the erlang-questions mailing list