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

Code after do-while(true) statement with no breaks isn't marked as unreachable #8923

Closed
danog opened this issue Dec 18, 2022 · 2 comments · Fixed by #8929
Closed

Code after do-while(true) statement with no breaks isn't marked as unreachable #8923

danog opened this issue Dec 18, 2022 · 2 comments · Fixed by #8929

Comments

@danog
Copy link
Collaborator

danog commented Dec 18, 2022

https://psalm.dev/r/918eba8573

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/918eba8573
<?php

function ret(): int {
    do {
        return 1;
    } while (true);
}
Psalm output (using commit 7d95f15):

ERROR: InvalidReturnType - 3:17 - Not all code paths of ret end in a return statement, return type int expected

@orklah
Copy link
Collaborator

orklah commented Dec 18, 2022

Probably a missing handling of do/while on ScopeAnalyzer:

if ($stmt instanceof PhpParser\Node\Stmt\While_

We have it for while and for but not for other loops

danog added a commit to danog/psalm that referenced this issue Dec 18, 2022
@danog danog mentioned this issue Dec 18, 2022
orklah added a commit that referenced this issue Dec 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants