nim-works / nimskull

An in development statically typed systems programming language; with sustainability at its core. We, the community of users, maintain it.
https://nim-works.github.io/nimskull/index.html
Other
275 stars 39 forks source link

fix(sem): avoid no-return false positives #1452

Closed saem closed 1 month ago

saem commented 1 month ago

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.

zerbina commented 1 month ago

/merge

github-actions[bot] commented 1 month ago

Merge requested by: @zerbina

Contents after the first section break of the PR description has been removed and preserved below:


## Notes for Reviewers * Found via Loony CI and reduced thanks to @alaviss