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
279 stars 39 forks source link

fix(sem): analysis considers nested noreturn #1450

Closed saem closed 2 months ago

saem commented 2 months ago

Summary

No-return analysis ensures that nested final expressions ( block/case/if/try ) are accounted for no-return itself.

Details

Prior to this change if the last expression within a greater expression was a no-return expression it would not be deemed as such if it was a block/case/if/try , instead errors would be raised related to discard checks or that path not resulting in the correct type.

For example, the following would result in an error where 0 must be used or discarded:

proc foo() =
  let x =
    if false: 10
    else:
      block:
        return

Fixes https://github.com/nim-works/nimskull/issues/1440

saem commented 2 months ago

/merge

github-actions[bot] commented 2 months ago

Merge requested by: @saem

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


## Notes for Reviewers * it's cleaner than I thought * let me know if there is a better module to use than `ast_query`, `trees` didn't seem right