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

Erlang 19 dialyzer fixes for S3 #305

Merged
merged 2 commits into from Sep 12, 2016

Conversation

waisbrot
Copy link
Member

@waisbrot waisbrot commented Sep 9, 2016

Dialyzer no longer adds an implicit |undefined to types inside records, so it rejects most of erlcloud.

I'd like to do this in multiple PRs, one per module (except for tiny modules) so that it doesn't feel hopeless to review. If you'd rather one mega-PR, I can do that instead.

This takes care of erlcloud_s3 (starting here because this is the module that bit me), though the header file changes solve a large number of R19 dialyzer complaints across the board.

@waisbrot waisbrot changed the title Erlang 19 dialyzer fixes Erlang 19 dialyzer fixes for S3 Sep 9, 2016
@@ -42,7 +42,7 @@
secret_access_key::string()|undefined|false,
security_token=undefined::string()|undefined,
%% epoch seconds when temporary credentials will expire
expiration :: pos_integer(),
expiration=undefined :: pos_integer()|undefined,
Copy link
Collaborator

Choose a reason for hiding this comment

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

i wonder why it's defaulted only here. is this necessary?
i guess we default it to undefined everywhere or nowhere, agree?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not necessary; I did it because it's in a block of others that all have an explicit default value and security_token right above this already had an explicit-undefined default.

I think that most of the values that get an implicit undefined do that from laziness, but some actually mean it. For example, all the response-related values below this in the record are definitely undefined until the response comes back and they get filled in.

My preference would be to make defaults explicit, because then x=undefined::integer()|undefined means "this can actually be undefined (because it's filled in conditionally, or there's a special meaning when it's not defined)" and x::integer()|undefined means "this is lazy-code and we don't actually know if x needs to accept a value of undefined.

Odds of someone carefully refactoring the whole code-base to eliminate unnecessary implicit undefineds are real low, though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with you that non explicit setting is more laziness and just making dializer happy without making code cleaner and thus also prefer explicit setting.

let's leave it here as is.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have no strong feeling on this. As long as the specs correctly say it can be undefined, knowing that this is the default value for records where the field is not set seems fine. Explicitly calling out the default is helpful but doesn't seem needed to me.

@motobob
Copy link
Collaborator

motobob commented Sep 12, 2016

@nalundgaard any feedback?

Request3 = erlcloud_retry:request(Config, Request2, fun s3_result_fun/1),
erlcloud_aws:request_to_return(Request3).
{RequestHeaders2, RequestBody} = case Method of
M when M =:= get orelse M =:= head orelse M =:= delete ->
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason not to use ; over orelse?

Copy link
Collaborator

Choose a reason for hiding this comment

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

it was there before. this is just code move.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep. Let's merge it.

@nalundgaard
Copy link
Contributor

I think I am 👍 on the change. I asked a few questions above, but neither is really an issue.

@motobob
Copy link
Collaborator

motobob commented Sep 12, 2016

okay...i hear no serious arguments so 👍

@motobob motobob merged commit 81243b1 into erlcloud:master Sep 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants