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

erl_lint: Warn on matching float 0.0 #7521

Merged

Conversation

jhogberg
Copy link
Contributor

@jhogberg jhogberg commented Aug 1, 2023

As announced on the forum, 0.0 will no longer match -0.0 in OTP 27 and vice versa.

This PR for OTP 26.1 adds a warning in anticipation of that.

@jhogberg jhogberg added team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI labels Aug 1, 2023
@jhogberg jhogberg added this to the OTP-26.1 milestone Aug 1, 2023
@jhogberg jhogberg requested a review from bjorng August 1, 2023 11:30
@jhogberg jhogberg self-assigned this Aug 1, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2023

CT Test Results

       2 files       89 suites   43m 33s ⏱️
1 917 tests 1 868 ✔️ 48 💤 1
2 211 runs  2 160 ✔️ 50 💤 1

For more details on these failures, see this check.

Results for commit 5e193bd.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@jhogberg jhogberg force-pushed the john/stdlib/lint-match-float-zero/OTP-18696 branch from 260d6d1 to 5e193bd Compare August 2, 2023 08:19
@jhogberg jhogberg merged commit 061bec4 into erlang:maint Aug 11, 2023
11 of 15 checks passed
gonzalobf pushed a commit to gonzalobf/recon that referenced this pull request Sep 21, 2023
In OTP-27, `+0.0` and `-0.0` will no longer be the exact number so they
added a compilation warning in OTP-26.1 to warn when a float 0.0 is
getting match without specifying the sign:

```
rebar3 compile                                                                                                                                                                               0s
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling recon
src/recon_alloc.erl:706:7: Warning: matching on the float 0.0 will no longer also match -0.0 in OTP 27. If you specifically intend to match 0.0 alone, write +0.0 instead.
src/recon_alloc.erl:706:11: Warning: matching on the float 0.0 will no longer also match -0.0 in OTP 27. If you specifically intend to match 0.0 alone, write +0.0 instead.
```

Longer explanation about why are not the same [1]

Pull request adding the warning [2]

[1] https://erlangforums.com/t/in-erlang-otp-27-0-0-will-no-longer-be-exactly-equal-to-0-0/2586
[2] erlang/otp#7521
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants