Skip to content

Commit

Permalink
Fix Dialyzer by copying some type specs that Jiffy doesn't export
Browse files Browse the repository at this point in the history
Since Erlang/OTP 26.0, Dialyzer enables by default "unknown" types warnings
https://www.erlang.org/patches/otp-26.0
  • Loading branch information
badlop committed Feb 16, 2024
1 parent b4f2c73 commit e24ac29
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions include/mod_matrix_gw.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,19 @@
implicit_room_creator :: boolean(),
updated_redaction_rules :: boolean()
}).

%% Jiffy doesn't export those type specs, so they are copied here from
%% https://github.com/davisp/jiffy/blob/master/src/jiffy.erl

-type json_value() :: null
| true
| false
| json_string()
| json_number()
| json_object()
| json_array().
-type json_array() :: [json_value()].
-type json_string() :: atom() | binary().
-type json_number() :: integer() | float().
-type json_object() :: {[{json_string(),json_value()}]}
| #{json_string() => json_value()}.
2 changes: 1 addition & 1 deletion src/mod_matrix_gw.erl
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ sign_json(Host, JSON) ->
binary(),
[binary()],
[{binary(), binary()}],
none | jiffy:json_object(),
none | json_object(),
[any()],
[any()]) -> {ok, any()} | {error, any()}.

Expand Down
2 changes: 1 addition & 1 deletion src/mod_matrix_gw_room.erl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
sender :: binary(),
prev_events :: [binary()],
origin_server_ts :: integer(),
json :: jiffy:json_object(),
json :: json_object(),
state_map}).

-record(data,
Expand Down

0 comments on commit e24ac29

Please sign in to comment.