Skip to content

Enum.max_by/3 and Enum.min_by/3 dialyzer fixes #10383

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

Merged
merged 1 commit into from
Oct 1, 2020

Conversation

davydog187
Copy link
Contributor

@davydog187 davydog187 commented Oct 1, 2020

I was getting dialyzer errors when calling min_by and max_by arity 3.

# Code
Enum.min_by(matches, & &1.utc_start_time, DateTime)

# Error
lib/trailblazer_web/controllers/api/v1/match_controller.ex:56:call
The function call will not succeed.

Enum.max_by(_matches :: [any(), ...], (_ -> any()), DateTime)

breaks the contract
(t(), (element() -> any()), (() -> :empty_result)) :: element() | :empty_result
when empty_result: any()

@josevalim josevalim merged commit 68a4a31 into elixir-lang:master Oct 1, 2020
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@michallepicki
Copy link
Contributor

@davydog187 I am curious, did you have this problem with 1.11.0-rc.0? I thought I fixed it in #10050 already. I cannot reproduce with 1.11.0-rc.0 and looking at your PR it doesn't really change the specs, just merges existing specs into one (?)

@davydog187
Copy link
Contributor Author

@michallepicki I didn't. Let me fire it up and see if I can reproduce

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.

3 participants