Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OS] fix type declaration #3057

Merged
merged 1 commit into from
Mar 18, 2021
Merged

[OS] fix type declaration #3057

merged 1 commit into from
Mar 18, 2021

Conversation

NelsonVides
Copy link
Collaborator

In case I’m mixing up some type, I’m sharing this error dialyzer should have complained about:

-callback encode(Request :: muc_light_encode_request(), OriginalSender :: jid:jid(),
says that encode’s first parameter is a muc_light_encode_request()

encode({#msg{} = Msg, AffUsers}, Sender, {RoomU, RoomS} = RoomUS, HandleFun) ->
the first head of encode in the actual implementation takes a {msg(), aff_users()}

-type muc_light_encode_request() :: {get, #config{} | #affiliations{} | #info{} | #blocking{}}
| {set, #affiliations{}, OldAffUsers :: aff_users(),
NewAffUsers :: aff_users()}
| {set, #blocking{}}
| {set, #create{}, UniqueRequested :: boolean()}
| {set, #destroy{}, AffUsers :: aff_users()}
| {set, #config{}, AffUsers :: aff_users()}
| {error, bad_request}.
does not define {msg(), aff_users()} as any of the possibilities for this type

This arose when writing a custom codec for a client that would modify a couple of requests but just forward everything else to the modern codec, only when calling encode directly with an actual value, dialyzer complained.

In case I'm mixing up some type, I'm sharing this error dialyzer should have complained about:
1. mod_muc_light_codec.erl#L32 says that encode’s first parameter is a muc_light_encode_request()
2. mod_muc_light_codec_modern.erl#L50 the first head of encode in the actual implementation takes a {msg(), aff_users()}
3. include/mod_muc_light.hrl#L115-L122 does not define {msg(), aff_users()} as any of the possibilities for this type
This arose when writing a custom codec for beekeeper that would modify a couple of requests but just forward everything else to the _modern codec, only when calling encode directly with an actual value, dialyzer complained.
@codecov
Copy link

codecov bot commented Mar 17, 2021

Codecov Report

Merging #3057 (38b0c9a) into master (135fec2) will decrease coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3057      +/-   ##
==========================================
- Coverage   78.53%   78.50%   -0.04%     
==========================================
  Files         378      378              
  Lines       31119    31119              
==========================================
- Hits        24440    24429      -11     
- Misses       6679     6690      +11     
Impacted Files Coverage Δ
src/elasticsearch/mongoose_elasticsearch.erl 76.92% <0.00%> (-7.70%) ⬇️
src/mongoose_tcp_listener.erl 76.59% <0.00%> (-4.26%) ⬇️
src/mam/mod_mam_elasticsearch_arch.erl 86.60% <0.00%> (-1.79%) ⬇️
...c/global_distrib/mod_global_distrib_server_mgr.erl 76.83% <0.00%> (-0.57%) ⬇️
src/ejabberd_s2s_out.erl 57.89% <0.00%> (-0.46%) ⬇️
src/pubsub/mod_pubsub_db_mnesia.erl 92.40% <0.00%> (-0.43%) ⬇️
src/ejabberd_c2s.erl 89.25% <0.00%> (-0.23%) ⬇️
src/mod_muc_room.erl 77.50% <0.00%> (-0.06%) ⬇️
src/mod_muc_log.erl 77.72% <0.00%> (ø)
src/ejabberd_sm.erl 76.21% <0.00%> (+0.30%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 135fec2...38b0c9a. Read the comment docs.

Copy link
Collaborator

@DenysGonchar DenysGonchar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@chrzaszcz chrzaszcz merged commit 8f49c41 into master Mar 18, 2021
@chrzaszcz chrzaszcz deleted the esl/fix_muclight_type branch March 18, 2021 06:58
@leszke leszke added this to the 4.2.0 milestone Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants