[erlang-questions] Dialyzer and parameterized modules

Kostis Sagonas kostis@REDACTED
Fri Oct 1 16:24:09 CEST 2010


Fernando Benavides wrote:
> Hi all,
>  
> I know that since v2.2.0, dialyzer has support for parameterized
> modules, but somehow it's not working for me. 
> Lets say that, for some unknown reason (o_O), I want a parameterized
> module for atom queues. 
> I write this tiny parameterized module then: 
>  ....  CODE SNIPPED
>         
> If I run dialyzer on it, no warnings are reported. But it has no specs
> and I like to compile my code with warn_missing_spec. The compiler says
> that the specs for pop/0 and push/1 are missing. So, I add the specs... 
>  ....  CODE SNIPPED
> Compiler is not complaining anymore, which is great. But when I try to
> dialyze the module, I get:
>         Contract for function that does not exist: atom_queue:pop/0 
>         Contract for function that does not exist: atom_queue:push/1 
>         
> I change the specs to satisfy dialyzer, like this:
>  ....  CODE SNIPPED
> 
> But, of course, I can't compile that code:
>         spec for undefined function atom_queue:pop/1
>         spec for undefined function atom_queue:push/2 
> 
> So, basically the question is: How can I write a parameterized module
> with specs that satisfies both dialyzer and erlc at the same time?

First of all, let me congratulate you for your discipline in Erlang 
programming.

However, I am afraid you have run into a problem here in what you want 
to do.  The problem is that the infrastructure of parameterized modules 
was developed before -specs were introduced to Erlang.  Consequently, 
the parse transform (or equivalent) that does the transformation into 
"usual" Erlang code is spec-agnostic.  So, this is not a dialyzer issue 
but a problem in the translation of parameterized modules.

I will leave this to somebody who understands that translation handle 
the issue.

Kostis


More information about the erlang-questions mailing list