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

Fix doctest warning #14

Merged
merged 2 commits into from
Dec 18, 2024
Merged

Fix doctest warning #14

merged 2 commits into from
Dec 18, 2024

Conversation

billylanchantin
Copy link
Member

Since Elixir 1.17 this code was generating a warning:

iex> import CompareChain
iex> a = ~D[2017-03-31]
iex> b = ~D[2017-04-01]
iex> a < b
false
iex> compare?(a < b, Date)
true

Specifically, a < b generates a warning about comparing structs. This is not unexpected (it's the whole point of CompareChain after all). But there isn't a good way to circumvent the warning. See the discussion here:

https://elixirforum.com/t/elixir-v1-18-0-rc-0-released/68015/36

This PR works around the issue by removing that code and instead explaining what's going on in an info block:

Screenshot 2024-12-18 at 11-32-30 CompareChain — compare_chain v0 5 0

I also tacked on a small refactor.

Since Elixir 1.17, `iex> a < b` in the docteset
emitted a warning. The workaround to hide the
offending code from the compiler is too
distracting. My solution is to move that code into
an info block and explain things in words.
This is just some bad code. A linter
would've caught this.
@billylanchantin billylanchantin requested a review from a team as a code owner December 18, 2024 16:34
@billylanchantin billylanchantin merged commit ad75c19 into main Dec 18, 2024
12 checks passed
@billylanchantin billylanchantin deleted the bl-fix-doctest-warning branch December 18, 2024 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant