dialyzer and ets:select

Raimo Niskanen raimo@REDACTED
Wed Mar 22 16:50:53 CET 2006


Since a match spec can build any term the signature correction should be:
        Object = term()

The rest of the ets:select/2,3 documentation describes a lot
about how to build various result terms, so in this case
it seems it is only the documentation signature that is wrong.
Probably a cut-and-past bug from e.g ets:lookup.


kostis@REDACTED (Kostis Sagonas) writes:

> 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".
> 

Already corrected in the R10B-10 documentation.

 
-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list