Skip to content

Commit 6b7a1f3

Browse files
committed
darned dialyzer
1 parent 0d83b42 commit 6b7a1f3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ra_kv.erl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424

2525

2626
-define(STATE, ?MODULE).
27+
-define(TUPLE(A, B), [A | B]).
2728

2829
-type key() :: binary().
2930
-type value() :: term().
3031

3132
-record(?STATE, {keys = #{} ::
32-
#{key() := [ra:index() | Hash :: non_neg_integer()]}}).
33+
#{key() => ?TUPLE(non_neg_integer(), Hash :: integer())}}).
3334

3435

3536
-record(put, {key :: key(),
@@ -107,11 +108,14 @@ put(ServerId, Key, Value, Timeout) ->
107108
init(_) ->
108109
#?MODULE{}.
109110

111+
%% we use improper lists in this module
112+
-dialyzer({no_improper_lists, [apply/3]}).
113+
110114
apply(#{index := Idx} = Meta,
111115
#put{key = Key,
112116
meta = #{hash := Hash}},
113117
#?STATE{keys = Keys} = State0) ->
114-
State = State0#?STATE{keys = maps:put(Key, [Idx | Hash], Keys)},
118+
State = State0#?STATE{keys = Keys#{Key => ?TUPLE(Idx, Hash)}},
115119
{State, {ok, Meta}, []}.
116120

117121
live_indexes(#?STATE{keys = Keys}) ->

0 commit comments

Comments
 (0)