Reject certain code that should return but doesn't#502
Merged
cburgdorf merged 1 commit intoargotorg:masterfrom Aug 7, 2021
Merged
Reject certain code that should return but doesn't#502cburgdorf merged 1 commit intoargotorg:masterfrom
cburgdorf merged 1 commit intoargotorg:masterfrom
Conversation
cburgdorf
commented
Aug 6, 2021
| if val > 1: | ||
| return 5 | ||
| else: | ||
| x = 1 |
Collaborator
Author
There was a problem hiding this comment.
This was an extra error in the test file that I think we didn't intent to test for here
2f5cff9 to
17e434f
Compare
Codecov Report
@@ Coverage Diff @@
## master #502 +/- ##
==========================================
- Coverage 87.72% 87.69% -0.03%
==========================================
Files 80 80
Lines 5272 5276 +4
==========================================
+ Hits 4625 4627 +2
- Misses 647 649 +2
Continue to review full report at Codecov.
|
g-r-a-n-t
reviewed
Aug 6, 2021
| } => { | ||
| let body_returns = all_paths_return_or_revert(body); | ||
| let or_else_returns = or_else.is_empty() || all_paths_return_or_revert(or_else); | ||
| let or_else_returns = !or_else.is_empty() && all_paths_return_or_revert(or_else); |
Collaborator
There was a problem hiding this comment.
we could just get rid of the is_empty check, as all_paths_return_or_revert(or_else) will return false for an empty vec
Collaborator
Author
There was a problem hiding this comment.
Ah sure, I'll get that updated 👍
g-r-a-n-t
approved these changes
Aug 6, 2021
17e434f to
f4ddda2
Compare
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.
What was wrong?
As described in #497 the following code does compile in master but should generate a user error instead. It needs to error because the code is missing a return statement since it is not guaranteed that the execution follows the arm of the
ifstatement.How was it fixed?
The check in
all_paths_return_or_revertis wrong because it counts a missingelsebranch as if the code returns when clearly a missingelsebranch shouldn't indicate such thing.