dialyzer and ets:select

Kostis Sagonas <>
Wed Mar 22 14:48:39 CET 2006


Samuel Rivas wrote:
 >
 > Seems that dialyzer makes a wrong typing for ets:select. I wrote a
 > little module to check it:
 > 
 > -module(ets_fail).
 > -export([foo/1]).
 > 
 > foo(Table) ->
 >    Tuples = ets:select(Table, [{{'_', '$1', '$2'}, [], ['$$']}]),
 >    [list_to_tuple(Tuple) || Tuple <- Tuples].

Thanks for the report.  I will refrain from commenting on the
choice of names for variables in your program -- this is not
what confused Dialyzer, but it surely confused me...


ets:select/2 is one of the BIFs implemented in C.  For these BIFs,
Dialyzer has hard-coded knowledge about its types, obtained mostly
by consulting the Erlang/OTP online implementation.  In this case,
it reads:

  select(Tab, MatchSpec) -> [Object]

    Types:

      Tab = tid() | atom()
      Object = tuple()
      MatchSpec = match_spec()

Your example shows that the documentation is not correct.

Can somebody from the OTP team tell us the correct return type of
ets:select/2 ?

Thanks,
Kostis

PS. (Unrelated)

    One more thing needs to be fixed in the OTP documentation. For
	lists:split/2 
    the first argument should read starting from "0" rather than "1".




More information about the erlang-questions mailing list