[erlang-questions] Dialyzer HttpPacket Waring (bug?)

Edmond Begumisa <>
Mon Feb 28 21:23:33 CET 2011


On Tue, 01 Mar 2011 07:10:44 +1100, Edmond Begumisa  
<> wrote:

> Hello all,
>
> I'm using erlang:decode_packet/3 to do some HTTP. When I use the  
> http_bin packet type and match the result, Dialyzer keeps warning about  
> my HttpString type being invalid indicating that it's expecting a  
> string() and not my binary(). Yet the documentation says (and tracing  
> confirms) that HttpString = string() | binary()
>
> For example...
>
> case erlang:decode_packet(http_bin, Bin, []) of
>     {ok, {http_error, <<"\r\n">>}, Rest} ->
>       ..
> end.
>
> Produces the warning..
>
> The pattern {'ok', {'http_error',  
> <<13:8/integer-unit:1,10:8/integer-unit:1>>}, Rest} can never match the  
> type {'error',_} | {'more','undefined' | non_neg_integer()} |  
> {'ok','http_eoh' | binary() | maybe_improper_list(binary() |  
> maybe_improper_list(any(),binary() | []) | byte(),binary() | []) |  
> {'http_error',string()} | {'http_request','DELETE' | 'GET' | 'HEAD' |  
> 'OPTIONS' | 'POST' | 'PUT' | 'TRACE' | string(),'*' | string() |  
> {'abs_path',string()} | {'scheme',string(),string()} |  
> {'absoluteURI','http' | 'https',string(),'undefined' |  
> non_neg_integer(),string()},{non_neg_integer(),non_neg_integer()}} |  
> {'http_response',{non_neg_integer(),non_neg_integer()},integer(),string()}  
> | {'http_header',integer(),atom() | string(),_,string()},binary()}
>
> I get the same warnings for matching other results containing the  
> HTTPString type (http_body, http_header, etc)
>
> If I change http_bin to http in that call to decode_packet,

and match a list "\r\n"...

> everything is fine. But I'm using binaries with bit-syntax everywhere  
> and would prefer not to decode lists. I can't simply ignore the warnings  
> either because they permeate to other functions and other applications  
> using my library (making it impossible to Dialyze other modules/apps  
> that use this module).
>
> Is this a bug in the spec definitions for decode_packet? Where does  
> Dialyzer even get those since decode_packet is in the erlang module?
> Is there a way to get Dialyzer to ignore particular lines in particular  
> files? I can't use the "-Wno_match" switch coz it affects either all  
> modules or none in the case where you're merging plt files as I do.
>
> - Edmond -
>


-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


More information about the erlang-questions mailing list