[erlang-bugs] binary:part/3

Lukas Larsson <>
Mon Feb 18 09:25:33 CET 2013


Thanks for bringing this to our attention, I've updated the relevant code.

Lukas

On 17/02/13 12:12, Michael Truog wrote:
> On 02/17/2013 02:59 AM, Kostis Sagonas wrote:
>> On 02/16/2013 06:25 AM, Michael Truog wrote:
>>> There is a problem with the binary:part type spec used by dialyzer (the function is a BIF), such that it thinks the Length is pos_integer() instead of integer().  A similar problem exists within the documentation here (with the Length type):
>>> http://www.erlang.org/doc/man/binary.html#part-3
>> First of all, the documentation you are pointing out specifies that the third argument is "Len = integer() >= 0" so Len should be declared as non_neg_integer(), not integer().
>>
>> Second, and more important, this has been corrected in R16A/R16B:
>>
>>    https://github.com/erlang/otp/blob/master/lib/stdlib/src/binary.erl#L186
>>
>> If you want a correction for a previous Erlang/OTP release, change the corresponding entry in file lib/hipe/cerl/erl_bif_types.erl
>>
>> Kostis
>>
> The documentation is wrong as you can see from the entry above:
> http://www.erlang.org/doc/man/binary.html#part-2
>
> The Len should be an integer() since negative Len values do work as mentioned within
> PosLen = part() = {Start :: integer() >= 0, Length :: integer()}
>
> binary:part/3 is just providing the same parameters without the tuple wrapper for PosLen.
> _______________________________________________
> erlang-bugs mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-bugs
>



More information about the erlang-bugs mailing list