-
Notifications
You must be signed in to change notification settings - Fork 19
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
Fix dialyzer warnings #72
Conversation
Fixes Dialyzer warning: The variable X__V can never match since previous clauses completely covered the type 'ok'
X__X::'dummy' can never succeed in test_command_support(Command)
eredis_cluster:qp/1 calls query/4 which can return {error, no_connection} This fixes a dialyzer warning in eredis_cluster_tests "pipeline": {'error', 'no_connection'} can never match the type [{'error','invalid_cluster_command' | 'no_connection' | 'tcp_closed' | bitstring()} | {'ok','undefined' | bitstring()}]
qa/1 and qa/2 return a list of what qw/2 returns, i.e redis_result()
The pattern {'ok', [ExpectedKey | _]} can never match the type [{'error','invalid_cluster_command' | 'no_connection' | 'tcp_closed' | bitstring()} | {'ok','undefined' | bitstring()}] | {'error','invalid_cluster_command' | 'no_connection' | 'tcp_closed' | bitstring()} | {'ok','undefined' | bitstring()}
This makes sure we run dialyzer on testcode during development and in CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose silencing the warnings is better than nothing, but these types are a bit of a mess.
include/eredis_cluster.hrl
Outdated
@@ -6,10 +6,11 @@ | |||
|
|||
-type redis_error_result() :: Reason::bitstring() | no_connection | |||
| invalid_cluster_command | tcp_closed. | |||
-type redis_success_result() :: Result::bitstring() | undefined. | |||
-type redis_success_result() :: bitstring() | [bitstring()] | undefined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where bitstring()
(any multiple of bits) is used in these types, it should really be binary()
(a multiple of 8 bits).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable, but I got stuck when looking into why the change was done in 071b73b.
Maybe it was in early development stages and was then just kept? Can an EVAL
return anything else in Redis?
Looking at eredis v1.0.8, used at the time of the change, it states binary()
in the return_value()
and no bitstring()
mentioned in the eredis code either. Sure looks like we should change this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EVAL can return RESP data, like any other redis command. It's not even possible to receive parts of a byte over TCP.
Possibly some other spec used bitstring() which gave some warning when it was used with binary(). Do you know if there were any occurrences of bitstring prior to that change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No bitstrings can be found in the repo prior to that change.
From OTP-26 the `unknown function or type` warning is on by default. Since dialyzer is now run from the test profile the test-applications are also needed in the PLT, but only in the test profile.
A bitstring() is any multiple of bits while binary() is a multiple of 8 bits. Since RESP is a binary protocol which uses control sequences encoded in standard ASCII, i.e. 8 bits, the type binary() is the proper type to use.
Run dialyzer on the test profile during make dialyzer, and in CI runs.
This PR fixes all dialyzer warnings found in the rebar3 test profile.
Fixes #71