[erlang-questions] http_uri_parse/1 inconsistent return value + dialyser headache

Zabrane Mickael zabrane3@REDACTED
Tue Aug 14 12:32:25 CEST 2012


Hi guys, Hi Kostis,

http_uri_parse/1 returns inconsistent value since 15RB.
I'm trying to build a wrapper around it to make my code works on =<R14B04 too.

Here's what i got so far:

-spec http_uri_parse([byte()]) -> {ok, tuple()} | {error, atom()}.
http_uri_parse(URL) when is_list(URL) ->
    case http_uri:parse(URL) of
        {ok,{Scheme, UserInfo, Host, Port, Path, Query}} -> %% >=R15B
            http_uri_parse_1(Scheme, UserInfo, Host, Port, Path, Query);
        {Scheme, UserInfo, Host, Port, Path, Query} -> %% =< R14B               <------- LINE 1106
            http_uri_parse_1(Scheme, UserInfo, Host, Port, Path, Query);
        Error ->
            Error
    end.

http_uri_parse_1(Scheme, UserInfo, Host, Port, Path, Query) ->
    {ok, {Scheme, UserInfo, Host, Port, Path, Query}}.

But Dilayzer isn't happy:

Checking whether the PLT /Users/younes/.otp_plt is up-to-date... yes
  Proceeding with analysis...
pimco.erl:1106: The pattern {Scheme, UserInfo, Host, Port, Path, Query} can never match the type {'error','no_scheme' | {_,atom(),_}}


Any hint/help to get rid of this warning?

Regards
Zabrane


More information about the erlang-questions mailing list