[erlang-questions] lists:unzip breaks dialyzer.
Kostis Sagonas
kostis@REDACTED
Tue Jun 17 15:07:41 CEST 2008
Adam Kelly wrote:
> Hi,
>
> I've just run into a weird problem with dialyzer. A module (see
> below) containing a call to lists:unzip with a list of more
> than a single tuple as an argument seems to crash dialyzer. Am I
> doing something wrong?
>
> Thanks,
> Adam.
>
> $ cat test_dia.erl
> -module(test_dia).
> -export([u/0]).
>
> u() ->
> lists:unzip([{a, 1}, {b, 2}]).
> $ erlc +debug_info test_dia.erl
> $ dialyzer -c test_dia.beam
> Checking whether the initial PLT exists and is up-to-date... yes
> Proceeding with analysis...
> =ERROR REPORT==== 17-Jun-2008::13:04:56 ===
> dialyzer: Internal problems were encountered in the analysis.
> $ dialyzer --version
> Dialyzer version v1.7.0
With the latest Dialyzer version (the one in R12B-3), I cannot reproduce
the error. I suggest you upgrade your Erlang/OTP installation to that
one -- there are many reasons to do so, not only Dialyzer-specific.
If, for whatever reason, this is not possible, and want to solve this
issue on your own, look at the definition of lists:unzip/1 types in your
Erlang/OTP installation (in the file lib/hipe/cerl/erl_bif_types.erl)
and compare them with the following definition:
type(lists, unzip, 1, Xs) ->
strict(arg_types(lists, unzip, 1), Xs,
fun ([Ps]) ->
case t_is_nil(Ps) of
true ->
t_tuple([t_nil(), t_nil()]);
false -> % Ps is a proper list of pairs
TupleTypes = t_tuple_subtypes(t_list_elements(Ps)),
lists:foldl(fun(Tuple, Acc) ->
[A, B] = t_tuple_args(Tuple),
t_sup(t_tuple([t_list(A), t_list(B)]),
Acc)
end, t_none(), TupleTypes)
end
end);
for possible differences.
Kostis
More information about the erlang-questions
mailing list