[erlang-questions] It appeared type error when I checked the code with dialyzer

Jesper Louis Andersen <>
Tue Dec 31 17:38:30 CET 2013


A tuple is not a dict() in general and furthermore a dict is opaque in the
sense you are not supposed to look at the internal structure. The reason
for the former is that the tuple {3, 5} is a counterexample to being a
dict. The reason for the latter is that if the dict module changes its
internal representation in the future, your code may not work.

The best fix is to remove the guard expression.

On Tue, Dec 31, 2013 at 8:33 AM, Solomon <> wrote:

> I define a function like this:
> f(T) when is_tuple(T)->
>   ...
>   dict:to_list(T),
>   ...
>   Ret.
> When I checked the code with dialyzer, it said, "The call
> dict:to_list(T::tuple()) does not have an opaque term of type dict() as 1st
> argument".
> There were no function to determine whether a term was dict(). So how I
> should fix this problem?
> Thanks.
> _______________________________________________
> erlang-questions mailing list
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20131231/9c48c511/attachment.html>

More information about the erlang-questions mailing list