[erlang-questions] Multiple types with the same name in Dialyzer

Kostis Sagonas kostis@REDACTED
Thu May 26 11:24:58 CEST 2011


Anthony Ramine wrote:
> Hi,
> 
> I have a type value/1 defined as `-type value(LabelT) :: ...` and I would
> like to have a type value/0 with a default LabelT type value like
> `-type value() :: value(binary())`. The file compiles just fine but Dialyzer
> complains that "Type value is already defined".
> 
> This exception is thrown from dialyzer_utils:add_new_type/6 [1] because the arity
> is not a part of a type identity, you can see this in erl_types:type_is_defined/3 [2].
> 
> What I really don't understand is that while the arity is not a part of it, whether
> the given type is opaque or not is, so you can have both `-type t()` and `-opaque t()`.
> 
> So I have two questions:
> 
> - Is being unable to have both type value/0 and value/1 a bug?
> - Does being able to have both type t opaque and non-opaque have any purpose?

Hi Antony,

We are aware of these issues and we are in the process of fixing them. 
Unfortunately, they require major surgery...

Sort answers to your questions:

  1. No -- just a current limitation that will be lifted soon, I hope.
  2. No -- it should be prohibited by erl_lint already; will happen.

Kostis



More information about the erlang-questions mailing list