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

Jay Nelson jay@REDACTED
Tue May 3 17:08:39 CEST 2011


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



More information about the erlang-bugs mailing list