Skip to content

Commit

Permalink
Fix dialyzer warnings.
Browse files Browse the repository at this point in the history
Fixed:
pokemon_pb.erl:52: The pattern <Default, _> can never match since previous clauses completely covered the type <_,'none'>
pokemon_pb.erl:53: The pattern <Val, _> can never match since previous clauses completely covered the type <_,'none'>
protobuffs.erl:373: Invalid type specification for function protobuffs:encode_field_tag/2. The success typing is (non_neg_integer(),0 | 1 | 2 | 5) -> [integer(),...]
protobuffs.erl:387: Invalid type specification for function protobuffs:encode_varint/1. The success typing is (integer()) -> [integer(),...]
protobuffs.erl:393: Invalid type specification for function protobuffs:encode_varint/2. The success typing is (integer(),[integer()]) -> [integer(),...]

Safe to ignore:
pokemon_pb.erl:46: The variable _ can never match since previous clauses completely covered the type #pikachu{}
  • Loading branch information
seancribbs committed Mar 7, 2013
1 parent d732191 commit 7c3612c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/pokemon_pb.erl
Expand Up @@ -48,7 +48,6 @@ encode_extensions(_) -> [].
iolist(pikachu, Record) -> iolist(pikachu, Record) ->
[pack(1, required, with_default(Record#pikachu.abc, none), string, [])]. [pack(1, required, with_default(Record#pikachu.abc, none), string, [])].


with_default(Val, none) -> Val;
with_default(Default, Default) -> undefined; with_default(Default, Default) -> undefined;
with_default(Val, _) -> Val. with_default(Val, _) -> Val.


Expand Down
8 changes: 4 additions & 4 deletions src/protobuffs.erl
Expand Up @@ -26,7 +26,7 @@
%% @doc A protcol buffers encoding and decoding module. %% @doc A protcol buffers encoding and decoding module.
-module(protobuffs). -module(protobuffs).


%% Pubic %% Public
-export([encode/3, encode_packed/3, decode/2, decode_packed/2]). -export([encode/3, encode_packed/3, decode/2, decode_packed/2]).


%% Used by generated *_pb file. Not intended to used by User %% Used by generated *_pb file. Not intended to used by User
Expand Down Expand Up @@ -372,7 +372,7 @@ typecast(Value, _) ->
%% @hidden %% @hidden
-spec encode_field_tag(FieldID :: non_neg_integer(), -spec encode_field_tag(FieldID :: non_neg_integer(),
FieldType :: encoded_field_type()) -> FieldType :: encoded_field_type()) ->
binary(). iodata().
encode_field_tag(FieldID, FieldType) when FieldID band 16#3fffffff =:= FieldID -> encode_field_tag(FieldID, FieldType) when FieldID band 16#3fffffff =:= FieldID ->
encode_varint((FieldID bsl 3) bor FieldType). encode_varint((FieldID bsl 3) bor FieldType).


Expand All @@ -385,13 +385,13 @@ encode_varint_field(FieldID, Integer) ->


%% @hidden %% @hidden
-spec encode_varint(I :: integer()) -> -spec encode_varint(I :: integer()) ->
binary(). iodata().
encode_varint(I) -> encode_varint(I) ->
encode_varint(I, []). encode_varint(I, []).


%% @hidden %% @hidden
-spec encode_varint(I :: integer(), Acc :: list()) -> -spec encode_varint(I :: integer(), Acc :: list()) ->
binary(). iodata().
encode_varint(I, Acc) when I =< 16#7f -> encode_varint(I, Acc) when I =< 16#7f ->
lists:reverse([I | Acc]); lists:reverse([I | Acc]);
encode_varint(I, Acc) -> encode_varint(I, Acc) ->
Expand Down

0 comments on commit 7c3612c

Please sign in to comment.