[erlang-questions] When can an integer > 0 not be a pos_integer() in the Dialyzer?

Foolish Ewe <>
Sun Nov 16 00:27:18 CET 2008

Hi Kostis:

Wow that was fast :-).  Speaking of fast, am I imagining things or is the
dialyzer noticeably faster when using it in R12B4 than R12B3,

Thanks for the quick response.  I should have been a bit more thorough in
the command line options I used, I'm sorry about that.  My gut reaction is
to turn
on the strictest possible checking in any static analysis tool, I'd much
rather sweat
it now than be chasing run time errors later.

Bill M.

On Sat, Nov 15, 2008 at 3:39 AM, Kostis Sagonas <> wrote:

> Bill M. wrote:
>> Hello All:
>> Please consider the following functions
>> (which perform a sieve of Eratosthenes to find all primes < N where N > 1,
> ... CODE OMITTED ...
>  Running the dialyzer from R12B4 gives (Note, I had to make the lines
>> in the code snippet above fit in 80 columns or less, so the line
>> number might be off):
>> test.erl:20: Type specification test:list_primes_helper/2 ::
>> (MaxFactor::pos_integer(),PrimeCandidates::[pos_integer()]) ->
>> [pos_integer()] is a subtype of the success typing:
>> (pos_integer(),[integer()]) -> [integer()]
> Well, running dialyzer on your code will not give you this.
> You will only get this if you explicitly turn on the option -Woverspecs.
> You should not.
> From the options that are turned off by default, the only two options we
> recommend turning on are: -Wunmatched_returns and -Wunderspecs
> The remaining options are mainly for developers & debugging.
> (The manual could have been more explicit regarding this point - it will be
> in the next version.)
>  My guess is dialyzer didn't accurately guess the type of lists:seq(2,N).
> Your guess is correct, but it also has to do with the fact that the spec
> for this function is not as refined as it can be.  In R12B-4, it reads:
> -spec(seq/2 :: (integer(),integer()) -> [integer(),...]).
> and it nowhere specifies that if you feed it two pos_integer() it will
> return a list of pos_integer().
> Kostis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081115/5f8daef0/attachment.html>

More information about the erlang-questions mailing list