[erlang-bugs] dialyzer typename/0 and typename/1 names are treated the same?

Kostis Sagonas <>
Wed Feb 20 11:34:59 CET 2013

On 01/22/13 05:28, ノートン ジョーセフ ウェイ ン wrote:
> Given the sample module below, dialyzer reports that f_datum is already defined.
> This behaviour is strange to me because I'm expecting f_datum/0 and f_datum/1 to be treated as two independent types.  Is this a bug or specification?

For the record: we have fixed this issue and have submitted a patch that 
is cooking in the master-pu branch.  Most likely it will end up in R16B 
so the typename/0 vs. typename/1 confusion will not cause dialyzer 
crashes like the one below:

> $ dialyzer --src --plt ~/.dialyzer_plt.R15B03  src/foobar.erl
>    Checking whether the PLT /Users/norton/.dialyzer_plt.R15B03 is up-to-date... yes
>    Proceeding with analysis...
> dialyzer: Analysis failed with error:
> Could not scan the following file(s): [{"/Users/norton/appfoobar/src/foobar.erl",
>                                          "Type f_datum already defined\n"}]

However, let me point out that the example program which was used to 
illustrate the problem is meaningless.

> -type foo() :: foo.
> -type bar(T) :: list(T).
> -type f_datum(T) :: foo() | bar(T).
> -type f_datum() :: f_datum(f_datum()).

In particular, the last type declaration is not well-founded: there 
cannot possibly be any term that belongs to this type. Although the 
patch we submitted for R16B will not detect such problems, bear in mind 
that a future version of dialyzer may scream bloody murder when given 
such (nonsensical) type declarations.


More information about the erlang-bugs mailing list