[erlang-questions] Ets match on a record vs Dialyzer

Paul Mineiro paul-trapexit@REDACTED
Fri Sep 18 21:09:33 CEST 2009

On Fri, 18 Sep 2009, Zoltan Lajos Kis wrote:

> Hello,
> I would like to match entries in an ets table based on some fields of
> records, as in the example module below.
> When using the _='_' form for defining the "don't care" record fields,
> Dialyzer emits the following (reasonable) warnings:
> rec.erl:6: Function p/0 has no local return
> rec.erl:9: Record construction #rec{x::1,y::'_',z::'_'} violates the
> declared type for #rec{}
> With multiple functions and modules, the no local return causes an an
> avalanche of further no local return's and never called's.
> Of course I could redefine the field types as {x::integer()|'_',
> y::integer()|'_', z::integer()|'_'} but I would prefer another match
> syntax or Dialyzer directive if available. So what choices do I have?

I've had this problem constantly.  I've moved away from relaxing the type
specification in the record, and towards using setelement/3 to hide from
the dialyzer.  It helps that when using mnesia you get
mnesia:table_info (Table, wild_pattern) to initialize the record.


-- p

More information about the erlang-questions mailing list