syn and syn_groups' local_member and member function args are not aligned
tsenturk opened this issue · comments
Hi,
syn:member
written as;
member(GroupName, Pid) ->
syn_groups:member(GroupName, Pid).
but syn_groups:member
is declared as;
member(Pid, GroupName)
as I checked syn_groups
other functions, to make alignment with them, seems syn_groups:member
should declare as
member(GroupName, Pid)
like syn_groups:leave
function.
There is same issue for local_member
on syn
and syn_groups
modules.
I've fixed these issues on
https://github.com/tsenturk/syn/pull/new/fix-syn-groups-member-local-member-declare
but not sure, eventually it seems a breaking change.
Thank you for your report. This is overly complicated: there's no need to break changes for this. The only issue here is a naming /spec mix up in the syn.erl
helper module.
For instance with syn:member/2
, the doc states:
syn:member(Pid, GroupName) -> boolean().
In the syn.erl
module there's indeed an inversion of the naming parameter (nice catch) which is incorrect:
-spec member(GroupName :: any(), Pid :: pid()) -> boolean().
member(GroupName, Pid) ->
syn_groups:member(GroupName, Pid).
but this is just a proxy to:
-spec member(Pid :: pid(), GroupName :: any()) -> boolean().
member(Pid, GroupName) ->
case find_groups_entry_by_name_and_pid(GroupName, Pid) of
undefined -> false;
_ -> true
end.
Which therefore receives the correct parameters.
So basically it's just a name shift, with no effect on functionality. syn:member/2
should have been:
-spec member(Pid :: pid(), GroupName :: any()) -> boolean().
member(Pid, GroupName) ->
syn_groups:member(Pid, GroupName).
Same goes for syn:local_member/2
. To fix this all is really needed is to invert the param names in the syn.erl
module for these two functions.
Would you like to create a new pull request with only these changes?
Yes, sure I can prepare another pull request for this. here; #58
First, I've think like you mentioned in your comment then I've figured out that other syn_groups
functions have (GroupName, Pid)
like declaration except these two (member
, local_member
) therefore I've propose this change on syn_groups
instead of syn
.
about functionality, I'm not sure as you are right now.
I've figured out this issue because dialyzer
does not like member
and local_member
calls, like following;
The function call will not succeed.
:syn.local_member(
<<69, 115, 105, 121, 111, 46, 69, 108, 101, 99, 116, 105, 111, 110, 46, 86, 111, 116, 101,
114, 46, 67, 104, 97, 105, 110>>,
_pid :: pid()
)will never return since it differs in arguments with
positions 1st from the success typing arguments:(pid(), any())
Unfortunately your PR has merge conflict because of recent changes in master.
Ok no worries, I will take this and fix the naming asap.
Thank you for your help.
ops, I'm quite sure I did create without any conlift but after all it possible :) sorry about it.
I hope, I could help.
Your welcome & thank you for this project.
All changes are now up. Thank you for your help.