Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion http_uri_parse/1 inconsistent return value + dialyser headache
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Zabrane Mickael  
View profile  
 More options Aug 14 2012, 8:38 am
From: Zabrane Mickael <zabra...@gmail.com>
Date: Tue, 14 Aug 2012 14:38:19 +0200
Local: Tues, Aug 14 2012 8:38 am
Subject: Re: [erlang-questions] http_uri_parse/1 inconsistent return value + dialyser headache
Following Magnus & Motiejus great suggestions, here it is:

%-------- put this marco somewhere (.hrl, top of your .erl)
-ifdef(DIALYZER_CATCH).
-define(CATCH_FOR_DIALYZER(X), catch X).
-else.
-define(CATCH_FOR_DIALYZER(X), X).
-endif.

%------- the new code
-spec http_uri_parse([byte()]) -> {ok, tuple()} | {error, atom()}.
http_uri_parse(URL) ->
    case ?CATCH_FOR_DIALYZER(http_uri:parse(URL)) of
        {ok,{_, _, _, _, _, _}} = Ret15 -> %% >=R15B
            Ret15;
        {_, _, _, _, _, _} = Ret14 -> %% =< R14B
            {ok, Ret14};
        Error ->
            Error
    end.

Add this flag "-DDIALYZER_CATCH=1" to your Dialyzer command line:
$ dialyzer --src src --plt /path  ...  -DDIALYZER_CATCH=1

Everything's perfect now.

Thanks for sharing these guys.
You saved my day.

Regards,
Zabrane

On Aug 14, 2012, at 2:06 PM, Magnus Henoch wrote:

> Motiejus Jakštys <desired....@gmail.com> writes:

>> On Tue, Aug 14, 2012 at 2:04 PM, Magnus Henoch
>> <magnus.hen...@erlang-solutions.com> wrote:
>>> Zabrane Mickael <zabra...@gmail.com> writes:

>>> An advanced variant of that is to define a ?catch_for_dialyzer macro
>>> that expands to nothing for normal compilation, and to 'catch' when
>>> running Dialyzer.

>> Interesting. How do you know when you are running in dialyzer (i.e.
>> how would you define that macro)?

> The only way I know is to have your build system pass different -D flags
> for normal compilation and dialyzer.

> Regards,
> Magnus

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.