[erlang-bugs] Dialyzer bug with binary:compile_pattern/1

Ahmed Omar spawn.think@REDACTED
Tue May 3 17:45:27 CEST 2011


the return from binary:compile_pattern is {'bm',binary()} , while split is
expecting either binary() or {'cp', binary()}
I think the function compile_patters is the one to blame here cause in the
documentation it's said to return cp(), but i didn't digg into the module

On Tue, May 3, 2011 at 5:38 PM, Ahmed Omar <spawn.think@REDACTED> wrote:

> I don't think this is a bug in dialyzer. binary:compile_patter returns cp()
> not binary()
> so the warning is correct
>
>
> On Tue, May 3, 2011 at 5:08 PM, Jay Nelson <jay@REDACTED> wrote:
>
>> The following snippet of code gives a dialyzer error:
>>
>>   NL = list_to_binary(io_lib:nl()),
>>   LinesPattern = binary:compile_pattern(NL),
>>   Lines = [Line || Line <- binary:split(Bin, LinesPattern, [global,
>> trim]),
>>                    size(Line) > 0],
>>
>> The call
>> binary:split(Bin::binary(),LinesPattern::{'bm',binary()},['global' |
>> 'trim',...]) will never return since it differs in the 2nd argument from the
>> success typing arguments: (binary(),binary() | [binary()] |
>> {'cp',binary()},['global' | 'trim' | {'scope',{_,_}}])
>>
>> If the LinesPattern in the list comprehension is changed to NL, then there
>> is no error.
>>
>> It seems the return value of binary:compile_pattern/1 is not compatible
>> with the call to binary:split/3.
>>
>> jay
>> _______________________________________________
>> erlang-bugs mailing list
>> erlang-bugs@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-bugs
>>
>
>
>
> --
> Best Regards,
> - Ahmed Omar
> http://nl.linkedin.com/in/adiaa
> Follow me on twitter
> @spawn_think <http://twitter.com/#!/spawn_think>
>
>


-- 
Best Regards,
- Ahmed Omar
http://nl.linkedin.com/in/adiaa
Follow me on twitter
@spawn_think <http://twitter.com/#!/spawn_think>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20110503/13c2f7ea/attachment.htm>


More information about the erlang-bugs mailing list