-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sem): avoid no-return false positives (#1452)
## Summary no-return analysis now no longer confuses `void` branches for true no-returns. ## Details No-return analysis now dives into the trees of `if/try/block/case` statements in order to determine if they are in fact no-return scenarios. This is only done for the statement variety. The updated analysis besides being more correct, in that it avoids false positive no-return identification, it still allows for a number of false negatives. Chiefly that unstructured exits ( `return/break/raise` ) are only considered in the trailing position of statement lists and not part way through. This is considered acceptable as there is an overall improvement in accuracy and it should cover most code. This includes a fix for an NPE crash in discard-or-use error reporting.
- Loading branch information
Showing
3 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
discard """ | ||
description: ''' | ||
Ensure nested non-noreturn statements aren't treated as such | ||
''' | ||
errormsg: "expression '10' is of type 'int literal(10)' and has to be used (or discarded)" | ||
line: 11 | ||
""" | ||
|
||
let x = | ||
if true: | ||
10 | ||
else: | ||
try: | ||
discard | ||
except: | ||
discard |