fix: resolve redundant clause warnings in Elixir 1.20#30
Merged
polvalente merged 1 commit intoJul 20, 2026
Merged
Conversation
Remove dead-code clauses in divide/2 and atan2/2 already matched by earlier clauses returning the same value, and fix a clause-ordering bug in pow/2 where the :neg_infinity zero-base case was unreachable because the non-finite catch-all matched first. Move it before the catch-all, symmetric with the :infinity case.
josevalim
approved these changes
Jul 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Elixir 1.20's gradual set-based type analysis flags three redundant clauses. Two were dead code already matched by earlier clauses; one was a clause-ordering bug that surfaced via the warning.
divide/2— Removeddef divide(n, b) when is_number(n) and b in [:infinity, :neg_infinity]. The earlierdivide(a, :infinity)anddivide(a, :neg_infinity)clauses already match and return0.pow/2— Moveddef pow(%Complex{re: re, im: im}, :neg_infinity) when re == 0 and im == 0before thepow(%Complex{}, z) when is_non_finite_number(z)catch-all. Previously the catch-all matched first, so this clause was unreachable dead code. It now producesnew(:infinity, 0)(0^-∞ = ∞), symmetric with the:infinityzero-base case (0^∞ = 0).atan2/2— Removeddef atan2(:nan, :nan). The earlieratan2(:nan, a) when is_number(a) or is_non_finite_number(a)already matches(:nan, :nan)and returns:nan.The corresponding test assertion for
pow(Complex.new(0, 0), :neg_infinity)is updated fromnew(:nan, :nan)tonew(:infinity, 0)to reflect the now-correct runtime behavior (the old assertion encoded the buggy catch-all result).mix compile --warnings-as-errorsis clean;mix testpasses 70/70 with no new failures.