dialyzer and ets:select

Samuel Rivas samuel@REDACTED
Wed Mar 22 13:46:25 CET 2006


Hello,

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


If you dilalyze it you'll get next complain:

  ets_fail,'-foo/1-letrec-lc$^0-',1}: Call to function
  {erlang,list_to_tuple,1} with signature (([any()]) -> tuple()) will fail
  since the arguments are of type (tuple())!

Which is not true:

2> Table = ets:new(table, [set,{keypos,1}]).
17
3> ets:insert(Table, {foo, bar, baz}).                  
true
4> ets:select(Table, [{{'_', '$1', '$2'}, [], ['$$']}]).
[[bar,baz]]
5> ets_fail:foo(Table).
[{bar,baz}]

-- 
	Samuel



More information about the erlang-questions mailing list