errors in gb_sets and gn_trees
Kostis Sagonas
kostis@REDACTED
Thu Sep 16 23:54:15 CEST 2010
Modules gb_sets and gb_trees each define an insert/2 function whose
documentation (for gb_sets) reads:
insert(Element, Set1) -> Set2
Types:
Element = term()
Set1 = Set2 = gb_set()
Returns a new gb_set formed from Set1 with Element inserted. Assumes
that Element is not present in Set1.
and whose code reads:
insert(Key, Val, {S, T}) when is_integer(S) ->
S1 = S+1,
{S1, insert_1(Key, Val, T, ?pow(S1, ?p))}.
insert_1(Key, Value, {Key1, V, Smaller, Bigger}, S) when Key < Key1 ->
case insert_1(Key, Value, Smaller, ?div2(S)) of
....
insert_1(Key, _, _, _) ->
erlang:error({key_exists, Key}).
Should the last line be a call to erlang:error/1 or to erlang:throw/1 ?
Kostis
More information about the erlang-questions
mailing list