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

Fix #22604: Make endsInNoReturn traverse the tree #22612

Merged
merged 6 commits into from
Sep 1, 2023

Conversation

SirOlaf
Copy link
Contributor

@SirOlaf SirOlaf commented Aug 31, 2023

Close #22604

endsInNoReturn now traverses relevant nodes to determine if the block really doesn't return.
Same story as in previous pr, improves type inference and unreachable code detection somewhat, iterator example also now not seen as a noreturn, so thanks for stopping the flag nonsense I was doing.

Alternative to #22608

@SirOlaf SirOlaf marked this pull request as ready for review August 31, 2023 23:46
@Araq
Copy link
Member

Araq commented Sep 1, 2023

Acceptable for now but the spec doesn't imply that type checking has to care about continue and other undisciplined crappy control flow.

@Araq Araq merged commit 3b206ed into nim-lang:devel Sep 1, 2023
16 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2023

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 3b206ed

Hint: mm: orc; opt: speed; options: -d:release
169444 lines; 9.033s; 611.168MiB peakmem

@metagn
Copy link
Collaborator

metagn commented Sep 1, 2023

Other languages have "never" types for this

@SirOlaf
Copy link
Contributor Author

SirOlaf commented Sep 1, 2023

Well I know nothing of language design, just (trying to) solve interesting looking problems.

You’re right though, never type looks pretty good compared to this.

@Araq
Copy link
Member

Araq commented Sep 1, 2023

Other languages have "never" types for this

That doesn't improve the situation all that much, so you introduce weirdo types that do not compose and need special handling elsewhere. What is a seq[Never]?

narimiran pushed a commit that referenced this pull request Sep 15, 2023
* Rewrite endsInNoReturn

* Handle `try` stmt again and add tests

* Fix unreachable code warning

* Remove unreachable code in semexprs again

* Check `it.len` before skip

* Move import of assertions

---------

Co-authored-by: SirOlaf <>
(cherry picked from commit 3b206ed)
narimiran pushed a commit that referenced this pull request Sep 15, 2023
* Rewrite endsInNoReturn

* Handle `try` stmt again and add tests

* Fix unreachable code warning

* Remove unreachable code in semexprs again

* Check `it.len` before skip

* Move import of assertions

---------

Co-authored-by: SirOlaf <>
(cherry picked from commit 3b206ed)
narimiran pushed a commit that referenced this pull request Sep 18, 2023
* Rewrite endsInNoReturn

* Handle `try` stmt again and add tests

* Fix unreachable code warning

* Remove unreachable code in semexprs again

* Check `it.len` before skip

* Move import of assertions

---------

Co-authored-by: SirOlaf <>
(cherry picked from commit 3b206ed)
narimiran pushed a commit that referenced this pull request Sep 18, 2023
* Rewrite endsInNoReturn

* Handle `try` stmt again and add tests

* Fix unreachable code warning

* Remove unreachable code in semexprs again

* Check `it.len` before skip

* Move import of assertions

---------

Co-authored-by: SirOlaf <>
(cherry picked from commit 3b206ed)
narimiran pushed a commit that referenced this pull request Sep 18, 2023
* Rewrite endsInNoReturn

* Handle `try` stmt again and add tests

* Fix unreachable code warning

* Remove unreachable code in semexprs again

* Check `it.len` before skip

* Move import of assertions

---------

Co-authored-by: SirOlaf <>
(cherry picked from commit 3b206ed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing type inference in loop + case + if + continue
3 participants